DEV Community

Vinkal Prajapati
Vinkal Prajapati

Posted on

Sidebar always shown.

Check out this Pen I made!

Sidebar
This sidebar is of full height (100%) and always shown.

!DOCTYPE html: This declaration specifies the document type and version of HTML being used. In this case, it's HTML5.

html: This tag represents the root of the HTML document.

head: This section contains meta-information about the HTML document, such as the viewport settings and styles.

meta name="viewport" content="width=device-width, initial-scale=1": This meta tag ensures that the web page is displayed correctly on various devices by setting the viewport width to the device width and scaling it to 1.

style: This tag contains the CSS styles for the document.

body: This tag represents the content of the HTML document, and it contains two main sections:

.sidenav: This is a div element with the class "sidenav" representing the sidebar navigation menu. It includes links to different sections of the page.

.main: This is a div element with the class "main" representing the main content area of the page. It has a left margin to accommodate the width of the sidebar.

CSS Styles:

.sidenav: This defines the styles for the sidebar, making it fixed, with a width of 160px, a dark background color, and links with specific styles.

.sidenav a: This defines the styles for the sidebar links, setting the font size, color, and padding.

.sidenav a:hover: This defines the styles for the sidebar links when hovered over, changing the text color.

.main: This sets the margin and font size for the main content area, allowing it to adjust according to the width of the sidebar.

@media screen and (max-height: 450px): This media query adjusts the styles when the screen height is 450px or less. In this case, it reduces the padding and font size of the sidebar links. This is often used for better responsiveness on smaller screens.

In summary, this code provides a basic HTML structure for a webpage with a responsive sidebar navigation menu using CSS styles. The sidebar collapses and adjusts its appearance for smaller screens, ensuring a better user experience on different devices.

Top comments (0)