chris
chris

Reputation: 3

Three horizontal stripes in CSS

I've created three horizontal stripes to create an extended flag that will run at the top of my page:

CSS

#main1 div{
width: auto;
height: 20px;
margin: 0px

HTML

<div id="main1">
<div style="background-color:red;"></div>
<div style="background-color:blue;"></div>
<div style="background-color:orange;"></div>

How to get it to stick right up to the edge of the browser? (as in no gaps on the left right or top)

And also is there any easier / better way I could have done this Keep in mind I'm very much a novice

Your help is much appreciated! Thanks

Upvotes: 0

Views: 3510

Answers (1)

Fabrizio Calderan
Fabrizio Calderan

Reputation: 123397

Remove any margin and padding from html and body elements, then use a single div with a linear-gradient as a background

Example: http://codepen.io/anon/pen/rOxEgJ

html, body { margin: 0; padding: 0 }


#flag {
   height : 100px;
   width  : 100%;
   background: linear-gradient(to bottom, 
       red    0%, red  33.33%, 
       blue   0%, blue 66.66%,        
       orange 0%);
}

Upvotes: 5

Related Questions