

Let’s add background-position to our already existing code which now looks like the following: 1.

In this case, you can also use CSS grid and JS for the mobile menu. Anyways, coming back to the responsiveness of background-image, we need something to center the image so that the position is fixed at the centre while background size is the cover i.e. Style the navbar for mobile devices using CSS media queries as shown below. The logic behind using the checkbox element is that when it's unchecked it'll have display: none whereas while checked it'll change the CSS property of the general sibling selector (~) by setting it to display: block Simply stated, you’re using the checkbox for toggling the hamburger and the navigation menus between the expanded and hidden states. Position: absolute /*WITH RESPECT TO PARENT*/ The Service menu needs a little bit of extra attention as you have to set display: none for normal conditions and set it to display: block when someone hovers on it. We’ll be using CSS Flexbox and applying hover effects for highlighting. Moving forward, let’s style the HTML navbar. Your HTML navbar structure is now complete.Īpplying Basic CSS: Utilities /* UTILITIES */ After all, we haven’t yet discussed the checkbox workflow. A bitmap image always has its own dimensions and its own aspect ratio.

The interpretation of the possible values depends on the image's own dimensions ( width and height ) and its own proportion (ratio between width and height ). We can skip the hamburger menu while building the desktop navbar. The CSS background-size property specifies the size of the background images. You'll have the dropdown menu inside the Service (main) menu.
