Another option with pure CSS would be something like this:
nav { margin: 0px auto; width: 100%; height: 50px; background-color: white; float: left; padding: 10px; border: 2px solid red; position: relative; z-index: 10; } nav:after { background-color: grey; content: ''; display: block; position: absolute; top: 10px; left: 10px; right: 10px; bottom: 10px; z-index: -1; }
<nav>Some text or anything</nav>
Demo here
Related Posts:
- CSS reset – What exactly does it do?
- When to use margin vs padding in CSS [closed]
- SVG center horizontal and vertical line
- Can I change Bootstrap button color?
- Is it bad practice to comment out single lines of CSS with //?
- How to draw a half circle (border, outline only) [closed]
- CSS Circle with border
- Set parent style via child
- What is the proper way to display a logo with CSS?
- Responsive font size in CSS
- How to make a vertical line in HTML
- CSS Font Border?
- How do I change the background color with JavaScript?
- Why em instead of px?
- Vertical Align Center in Bootstrap
- Button Center CSS
- Centering a background image, using CSS
- How to change the cursor into a hand when a user hovers over a list item?
- not:first-child selector
- CSS: center element within a element
- what is a parse error and how do I fix it
- Bootstrap NavBar with left, center or right aligned items
- How to make the overflow CSS property work with hidden as value
- How to make a sticky footer in react?
- How to push a footer to the bottom of page when content is short or missing?
- Linking to a pdf file with html
- Change TD border color with HTML or CSS
- Why adding version number to CSS file path?
- Hide text using css
- Changing the width of Bootstrap popover
- CSS background color not working
- Bootstrap transparent navbar
- jQuery toggle CSS?
- 100% DIV width is not really 100%
- CSS 3 slide-in from left transition
- CSS selectors ul li a {…} vs ul > li > a {…}
- Bootstrap scrollable panel
- CSS checkbox input styling
- Is there a CSS selector for elements containing certain text?
- How to place two divs next to each other?
- Background color in input and text fields
- CSS3 opacity gradient?
- CSS3 background image transition
- How to import Google Web Font in CSS file?
- CSS Equivalent of the “if” statement
- How to make div background color transparent in CSS
- Why does z-index not work?
- how to offset a CSS border up and left
- HTML iframe – disable scroll
- How to get height of div in px dimension
- Add a link to an image in a css style sheet
- Two Divs next to each other, that then stack with responsive change
- Customizing a WordPress theme without changing it?
- How can I insert HTML attributes with an existing TinyMCE button?
- Hiding certain panels in dashboard
- Create a full width responsive header image per page
- How can I enqueue a style only when a particular widget is active?
- customizing recent posts
- Why is WordPress changing my HTML code
- Best way to install Bulma (CSS Framework) with WordPress and Genesis
- How does a Child Theme works?
- Different css rules for TinyMCE and Gutenberg while using add_editor_style()
- Is it possible to edit the styling of the admin panel from within a custom theme?
- Selectbox in admin panel function linking to CSS
- Responsive Author Style in BBpress?
- List All Enqueued Scripts and Styles
- Adding logo to WordPress header
- Load jQuery only on home page
- Keeping CSS model open after form submission
- header_image() with CSS
- Sidebar button click redirect when user is not logged in instead displays it
- something strange is happening to my code
- Change a Page’s Header Image
- Add class to navigation link of page
- Keep comments but turn off commenting
- Trouble hiding menu on single page
- Simple way to style posts of a single category differently in the loop and in single
- How do I switch css class on post
- Getting out side of wp root folder from function.php using absolute path
- Change the search icon in twenty fourteen
- styling isnot working in wordpress theme
- Using True Type Fonts (ttf) [closed]
- Horizontal drop down category with hover effect working
- uncaught TypeError: Cannot read properties of null (reading ‘classList’) custom plugin
- How do I minify a plugins CSS/JS code?
- Im having trouble centering menu items in footer due to “flexbox”
- echo cutom css code to WordPress page template file ? is this safe?
- Broken theme, stylesheet is missing after uploading the right theme via FTP
- CSS does not Update
- Why child theme stylesheet takes long time to update?
- CSS loading as empty file in Custom Theme
- Force include a stylesheet from parent theme
- WordPress Admin Thickbox: Remove Margins/Padding
- Site name not showing in browser bar, only url
- Phone numbers showing same color as header [closed]
- How to change the menu color
- CSS changes not taking effect [closed]
- files disappearing from template
- WordPress CSS not working properly
- How to modify submit button on GravityForms