Skip to content

Instantly share code, notes, and snippets.

@NateWeiler
Last active April 23, 2020 18:04
Show Gist options
  • Save NateWeiler/4bd7f0997320d78bf583f9a6b176bbcc to your computer and use it in GitHub Desktop.
Save NateWeiler/4bd7f0997320d78bf583f9a6b176bbcc to your computer and use it in GitHub Desktop.
Text with different background and border color
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;
}
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
<style id="background-color-with-border.css">
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;
}
</style>
</head>
<body>
<nav>Some text or anything</nav>
<script id="jsbin-source-html" type="text/html"><!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
<nav>Some text or anything</nav>
</body>
</html>
</script>
<script id="jsbin-source-css" type="text/css">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;
}</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment