I see a lot of code dealing with percentages, but what if I just wanted a 100px bar in the top? I am only able to edit the CSS of this page, so can I do it without any use of HTML?
Use :before
pseudo-element:
body:before {
content: " ";
display:block;
width:100%;
height:100px;
background:blue;
}
With this you can change some properties and have this results:
body {
color:white;
margin:0;
}
body:before {
content: " ";
display:block;
position:absolute;
top:0;
width:100%;
height:100px;
background:blue;
z-index:-1;
}
<h1>The content will be above the bar</h1>
body {
margin:0;
}
body:before {
content: " ";
display:block;
width:100%;
height:100px;
background:blue;
}
<h1>The content will be under the bar</h1>
You can use a sized, laterally-repeating, linear-gradient:
html {
background: white linear-gradient( 0, blue, blue ) repeat-x;
background-size: 100px 100px;
}
Fiddle: http://jsfiddle.net/r5a2uabw/4/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With