• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 757
  • Last Modified:

Element not respecting CSS padding

I have a container element that is set to be width:100%.

In it there are two divs also set to 100% width.

So:
Container
  Div 1
  Div 2

Div 2 has text-align:right; and padding-right:90px;

It isn't respecting the padding set to the right. The text doesn't sit 90px from the right, it is sitting 0px from the right...???

How can I get the text in Div 2 to sit 90px from the right. I have tried placing an element in there that is 90px and floating it right, I have tried margins, and I even tried to set the width to be 100% - 90px but I couldn't get the javascript correct or something.

Please help!! Thanks!

Here is my css and HTML:
<style type="text/css">
.topRowWrapper {
	position:relative;
	height:85px;
	padding:3px;
	width:100%;
}
.topRowTitle {
	height:38px;
	font-size:20px;
	color:#000000;
	width:100%;
	border-bottom:1px solid #DBDBDB;
}
.topRowVidDesc {
	height:38px;
	font-size:12px;
	color:#000000;
	width:100%;
	padding-right:90px !important;
	text-align:right;
}
.videoTuts {
	position:absolute;
	top:0;
	right:0;
	height:75px;
	width:75px;
	margin:5px;
	background-color:#333333;
}
</style>
 
<div class="topRowWrapper">
	<div class="topRowTitle">Choose Site</div>
	<div class="topRowVidDesc">Video Description</div>
	<div class="videoTuts"><a href="includes/popup/video.jsp" class="popupVideo">Video Here</a></div>
</div>

Open in new window

0
Shaye Larsen
Asked:
Shaye Larsen
2 Solutions
 
mstrelanCommented:
Just remove width:100% from your inner divs.
<style type="text/css">
.topRowWrapper {
	position:relative;
	height:85px;
	padding:3px;
	width:100%;
}
.topRowTitle {
	height:38px;
	font-size:20px;
	color:#000000;
	border-bottom:1px solid #DBDBDB;
}
.topRowVidDesc {
	height:38px;
	font-size:12px;
	color:#000000;
	/*width:100%;*/
	padding-right:90px !important;
	text-align:right;
}
.videoTuts {
	position:absolute;
	top:0;
	right:0;
	height:75px;
	width:75px;
	margin:5px;
	background-color:#333333;
}
</style>
 
<div class="topRowWrapper">
	<div class="topRowTitle">Choose Site</div>
	<div class="topRowVidDesc">Video Description</div>
	<div class="videoTuts"><a href="includes/popup/video.jsp" class="popupVideo">Video Here</a></div>
</div>

Open in new window

0
 
David S.Commented:
Non-floated, non-absolutely-positioned block-level elements, like <div>s, are the full width of their parent by default. You often don't need to set width:100%.

Because you gave the element width:100% and padding-right:90px you're telling it to be 90px wider than the content area of its parent.

I suggest you read this: http://www.dynamicsitesolutions.com/css/box-models/
0
 
qwerty021600Commented:
Copy paste this code :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
.topRowWrapper {
        position:relative;
        height:85px;
        padding:3px;
        width:100%;
}
.topRowTitle {
        height:38px;
        font-size:20px;
        color:#000000;
        border-bottom:1px solid #DBDBDB;
}
.topRowVidDesc {
        height:38px;
        font-size:12px;
        color:#000000;
            margin-right: 90px;
        /*width:100%;*/
        padding-right:90px !important;
        text-align:right;
}
.videoTuts {
        position:absolute;
        top:0;
        right:0;
        height:75px;
        width:75px;
        margin:5px;
        background-color:#333333;
}
</style>

</head>

<body>
<div class="topRowWrapper">
        <div class="topRowTitle">Choose Site</div>
        <div class="topRowVidDesc">Video Description</div>
        <div class="videoTuts"><a href="includes/popup/video.jsp" class="popupVideo">Video Here</a></div>
</div>
</body>
</html>

it'll work.
0
 
mstrelanCommented:
@qwerty
margin-right: 90px;
padding-right: 90px;
the combination of these two makes the total margin 180px ....
0
 
Shaye LarsenAuthor Commented:
Thanks, I need these small lessons is css!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now