Reputation: 1017
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?
Upvotes: 4
Views: 839
Reputation: 38252
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>
Upvotes: 4
Reputation: 268364
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/
Upvotes: 3
Reputation: 1401
You can use the ::before
pseudo class on the <body>
element, or another top-level container.
body::before {
content: '';
display: block;
height: 100px;
background-color: blue;
}
Upvotes: 0
Reputation: 10772
Another solution, simply use a border-top
on the body
.
body {
border-top: 100px solid blue;
margin: 0;
}
Upvotes: 2
Reputation: 538
Add a border-top to your body. Than possibly pad your content accordingly.
Something possibly like this.
body {
border-top: 100px solid blue;
}
If you had any examples we could help in more detail.
Upvotes: 1
Reputation: 2122
I am not in front of a computer where I can try this right now, but it seems like you should be able to set the background color to white and then load a 100 pixel tall background image of your desired shade of blue and set the image to repeat in the x-direction (horizontally) but not the y direction
Upvotes: 1
Reputation: 28
Put this HTML at the very top of your page. First piece of code blow <body>
<div id="topBar"></div>
Here's the CSS:
#topBar {
height:100px;
background-color:#FFF;
}
Upvotes: 0