<span style="font-size:30px;cursor:pointer" onclick="openNav()">☰ </span>
<button style="font-size: 30px; cursor:pointer; border: none; background: none;" onclick="openNav()">☰</button>
<a href="#" style="font-size: 30px; border: none; background: none; text-decoration: none; color: black;" onclick="openNav()">☰</a>
the same way as you treat .closebtn use position: absolute, too.how can i adjust the placement of the hamburger?
The <span> element is typically used to group and style inline elements or text within a larger document. However, it is not inherently designed to be interactive or clickable like a button. When you want to create clickable elements on a web page, it is generally recommended to use the appropriate semantic HTML element for the purpose, such as the <button> element.
Here are some reasons why the <button> element is preferable for creating clickable elements instead of using a <span>:
- Semantics: The <button> element carries semantic meaning for user agents, assistive technologies, and search engines. It indicates to users and developers that the element is meant to be interacted with, triggering an action when clicked. This enhances accessibility and ensures a better understanding of the document structure.
- Keyboard Accessibility: Buttons have built-in keyboard accessibility features. Users can navigate through interactive elements using the keyboard, and the <button> element ensures that users can easily focus on and activate the button using the keyboard's Enter or Space key.
- Styling: While <span> elements can be styled to look like buttons using CSS, using the <button> element provides a consistent and predictable styling foundation. This can be especially beneficial when working with different browsers and devices, ensuring a more standardized appearance.
- Event Handling: The <button> element is designed to handle various events, such as click events, more effectively. This can simplify the process of adding JavaScript functionality to the button, making it easier to manage and maintain interactive behavior.
In contrast, using a <span> element for interactive purposes might not convey the intended semantics and could lead to issues related to accessibility, user expectations, and code maintainability.
<a href="#" class="closebtn" onclick="closeNav()">×</a>
.sidenav .closebtn {
position: absolute;
top: 0;
right: 8px;
font-size: 36px;
margin-left: 5px;
padding: 4px;
}
something like this, this is of course an example of what it could possibly look likethe same way as you treat .closebtn use position: absolute, too.
<a href="#"
style="position: fixed; top: 6rem; left: 1rem; font-size: 30px; border: none; background: none; text-decoration: none; color: black;"
onclick="openNav()">☰</a>
.hamburger-button {
position: fixed;
top: 6rem;
left: 1rem;
font-size: 30px;
border: none;
background: none;
text-decoration: none;
color: black;
}
<a href="#" class="hamburger-button" onclick="openNav()">☰</a>
https://forallthetime.com/BI-A/index.html
tryplease https://forallthetime.com/BI-A/index.html
on the hover, i get a wihte background / color
i would like to fix that
.sidenav .closebtn {
position: absolute;
top: 8px;
right: 25px;
font-size: 36px;
padding: 0;
}
.sidenav .closebtn:hover {
background-color: transparent;
color: white;
}
flex
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.