Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialerdragerdragsson
Courses Plus Student 5,887 PointsHeader collapsing, when smaller browser
Hello my site header is collapsing when i rezise my browser, and its cut off like 3mm at desktop view
all my other elements on the page is fixed, so when rezising window you can scroll to the side and down.
but the header gets cut off in the middle, heres pictures off it
http://imgur.com/QqfcdGg and http://imgur.com/0TAsEh5
so you can see that the header background and image are getting cut off, and also the headers bottom border.
heres the css
body {
background: url('../img/background.jpg');
font-family: 'Oswald', sans-serif;
color: #fff;
width: 100%;
}
header {
background-image: url('../img/texture-logo.png');
background-color:black;
background-size: 100%;
padding: 40px;
margin-bottom: 200px;
min-height: 100%;
}
header {
border-bottom: 5px solid white;
}
.main-logo {
width: 400px;
}
.main-wrapper {
width: 1500px;
margin: 0 auto;
padding-left: 5%;
padding-right: 5%;
}
.first-content img{
width: 200px;
height: 200px;
border: 5px solid white;
border-radius: 10px;
}
.first-content a:hover {
opacity: .7;
}
.first-content li {
float: left;
width: 200px;
}
.first-content ul li{
margin: 40px;
list-style: none;
}
.first-content {
text-align: center;
margin-left: auto;
margin-right: auto;
}
.first-content ul li p {
letter-spacing: 2px;
}
.second-content p{
color: #FFF;
}
.second-content {
clear:both;
width: 50%;
text-align: center;
position: relative;
margin-left: auto;
margin-right: auto;
border: 5px solid white;
border-radius: 40px;
margin-top: -80px;
overflow: visible;
}
footer {
clear:both;
text-align: center;
font-size: 20px;
color: #FF6600;
font-weight: 900;
}
footer {
border-top: 1px solid white;
}
/***BUTTON FOR SECOND CONTENT****/
.button {
padding-left: 5%;
padding-right: 5%;
padding-top: 5px;
border: 1px solid black;
border-radius: 20px;
background-color: #FF6600;
text-align: center;
margin-bottom: 2px;
}
.button {
font-weight: bold;
}
.button:hover {
background-color: #FF6633;
}
10 Answers
Kallil Belmonte
35,561 PointsAdding a " margin: 0; " on the body doesn't help?
If don't, please provide your HTML too.
The website is fixed and not responsive, right?
Kallil Belmonte
35,561 PointsI'm limited because I haven't the images to see the real result, but I made a little modifications, try this:
body {
background: url('../img/background.jpg');
font-family: 'Oswald', sans-serif;
color: #fff;
margin: 0;
width: 100%;
}
header {
background-image: url('../img/texture-logo.png');
background-color:black;
background-size: 100%;
padding: 40px;
margin-bottom: 200px;
min-height: 100%;
width: 1550px;
}
You also can make your own modifications in this code if it is right (or near).
erdragerdragsson
Courses Plus Student 5,887 Pointsyeah it works now when i rezise the browser, but when its in fullscreen (desktop size) the header gets cut off like 1 cm
Kallil Belmonte
35,561 PointsI can't see this because my screen is smaller, but you can adjust only the header's size to fix this?
erdragerdragsson
Courses Plus Student 5,887 Pointsyeah but if i add like 1600px to the width, the header spans further away, and i get scrollbars at desktop screen, and if someone is looking at the website with a even larger screen, the border would get cut off,
isnt there a way to make the header stay the same width as the browser (span the whole width)?
Kallil Belmonte
35,561 PointsI understand, but for what I've tested in your code, I would say that you has two options.
1-
Remove the .main-wrapper in you css and aply the following code at your header (change the height as you want):
header {
background-image: url('../img/texture-logo.png');
background-color:black;
background-size: 100%;
height: 500px;
margin-bottom: 200px;
border-bottom: 5px solid white;
}
As you resize your screen you will see your images content to change it's position, like a responsive website.
Or 2-
Give a fixed header, with an ending width and height, to seem like a fixed menu at the center of the screen.
erdragerdragsson
Courses Plus Student 5,887 PointsWhen i remove main wrapper, the images get wierd placements as my screen gets narrower, because it has no container with a set of width
Kallil Belmonte
35,561 PointsSorry, I missed this because the way that the page displays to me
erdragerdragsson
Courses Plus Student 5,887 PointsHeres a codepen of it! http://codepen.io/anon/pen/OPjrKa
Kallil Belmonte
35,561 PointsSo... in your case (fixed layout) I would do something like this: http://codepen.io/anon/pen/OPjGYB
erdragerdragsson
Courses Plus Student 5,887 Pointsyeah i see, its the same effect if you add the header in to the wrapper div, but i would like the header to span the full width, off the browser, because now it only spans the size of the window, so when i scroll to the right it get cut off
Kallil Belmonte
35,561 PointsYour layout is Fixed, so your header is Fixed, it means that in some point it must end, that's why I made this last codepen, if you search for fixed layouts you will see this similarity.
erdragerdragsson
Courses Plus Student 5,887 Pointsso there isnt any way to make it span all the width of the page
erdragerdragsson
Courses Plus Student 5,887 Pointsheres and description of the problem (i wrote this in another thread)
the headers background is black, and i have an image in the header, that is supposed to be the logo, my website is fixed so when i rezise the browser all the things stay put except the header, at desktop view it has a small cut, and when i rezise it it span the browser size, but when i scroll to the right to see all the content on the page it has a cut, because it only was spaning the browser window at small screen, and not across the whole page that is fixed
Kallil Belmonte
35,561 PointsIf it is, I don't know yet, sorry.
erdragerdragsson
Courses Plus Student 5,887 Pointsoh okey, i have another issue with the wrapper div, the images are centered wrong in the div, i had the same problem on another site i've made and i fixed it by doing text-align center. but it does not work here.
heres a picture off the padding on the side of the wrapper div http://imgur.com/dV4ZobL
you can see that the left sides padding are wider, than the right side.
Kallil Belmonte
35,561 PointsHi,
Maybe you can set a less number to your margin at ".first-content ul li {}". Or create a ".first-content ul li:first-child {}" and set a margin-left with a negative number.
erdragerdragsson
Courses Plus Student 5,887 Pointshey i made A noter thead about the div problem and fond the solution and it was identicall to your solution, and i also fixed the header, i made anoter div around it and gav it the full with of the page and now it work ed, thanks for taking your time help in me! I appreciate it
Kallil Belmonte
35,561 PointsYou're very welcome! : )
erdragerdragsson
Courses Plus Student 5,887 Pointserdragerdragsson
Courses Plus Student 5,887 PointsNo the margin did not work, and yeah the website is fixed.
heres the html