I’m trying converting my Photoshop design into a web site, manually writing HTML and CSS. It’s my first time doing this type of exercise, so I’m having a little problem from the get-go with page dimensions.
I did my PS design using a 1920px page width, this is the fullscreen result. Writing CSS, I set header width to 1920px and logo width to 150px (as in the PS file). But I obtain this (don’t worry about logo position).
As you can see, the page is very “zoomed in” and the scrollbar appears down below. I want to display the whole page without a scrollbar, just as in PS, keeping the same ratio between elements.
This is my HTML & CSS code for the header:
#logo img {
float: left;
width: 150px;
height: 150px;
}
#header {
position: absolute;
top: 0px;
left: 0px;
width: 1920px;
/* I also tried width: 100% */
height: 100px;
background: #000000;
}
<div id="header">
<div id="logo">
<img src="..codiceexportlogo.png" alt="logo">
</div>
</div>
As shown in the code, I also tried setting the header’s width to 100% but this way the logo proportion (150 px / 1920 px) was not respected.
How can I write in CSS: “1920 should be your 100% when visualizing the page with the browser”?
I’m sorry if this is a silly question but it’s my first time working with these tools.
2
Answers
I made this jsfiddle
You can check with a fluid
width: 100%
you should not have this horizontally scrollbarThen i added a
header_content
div with a fixed width of 520px (then you can see it is centered and well placed. but you will need to change that value according to your photoshop header width.Note : css
margin:0 auto
makes your div centered horizontally.Some additional HTML and CSS may solve the problem for you! And I’m considering you have to add the
menu
which you not yet done. Here is my solution. I put some helpful comment that you help you to understand the code properly. You can have same code at my codepen example.