/    Sign up×
Community /Pin to ProfileBookmark

Setting 100% width for an element, it doesn’t consider the scrollbar

Hi
I’ve a seimple code for create an black rectangle long as the entire body

The problem is that when i resize di windows and the body goes under the min-width, scrollbar appears and moving it i see that the black rectangel is “cut” in the part that exceed

Searching on internet, i’ve found that solution is to set margin and padding of the body element to 0px… in my case didn’t work

[code=php]
</head>

<style type”text/css”>

html, body
{
width: 100%;
min-width:500px;
height: 100%;
min-height:700px;
margin:0px;
padding: 0px;
}

#red {
position:absolute;
top:100px;
width:100%;
min-width:100%;
height:37%;
min-height:300px;
max-height:330px;
background: rgb(0,0,0);
margin: 0px;
padding: 0px;
}

</style>

<body>

<div id=”red”></div>

</body>
</html>
[/code]

to post a comment
CSS

4 Comments(s)

Copy linkTweet thisAlerts:
@American_horizoauthorMar 02.2013 — after some proofs, i noted that removig position:absolute, the problem solves

The fact is that i really need to se it in absolute position
Copy linkTweet thisAlerts:
@rtretheweyMar 03.2013 — It's hard to suggest a solution without knowing your overall design for the page. In your example code, you're positioning the #red <div> with respect to the <body> element. So when the browser window is changed to be narrower than your min-width setting for the <body>, part of that <body> element is cut off from view and the #red <div> is cut off along with it.

If you'll explain your layout in more detail, I'm sure someone can suggest a solution for you.
Copy linkTweet thisAlerts:
@brandonatorMar 03.2013 — html, body {height:100%;width:100%;overflow:hidden}

</body>

</html>
Copy linkTweet thisAlerts:
@American_horizoauthorMar 04.2013 — It's hard to suggest a solution without knowing your overall design for the page. In your example code, you're positioning the #red <div> with respect to the <body> element. So when the browser window is changed to be narrower than your min-width setting for the <body>, part of that <body> element is cut off from view and the #red <div> is cut off along with it.

If you'll explain your layout in more detail, I'm sure someone can suggest a solution for you.[/QUOTE]

i just want that red assumes the exact body width, not only the visible part
×

Success!

Help @American_horizo spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...