?
Solved

Why the same css element used in two different sections renders differently

Posted on 2011-03-18
9
Medium Priority
?
248 Views
Last Modified: 2012-08-13
Hello. I have a css element "promo-info" (it is declared as a class). I use it twice on one page, as seen in the code snippet below (labeled ***HTML****), but the output puts the promo-info element (contained within the left-top element) further to the right than its counter part contained within the left-bottom element (see screenshot to see what i'm talking about).

I've also supplied the css code for this section as well.

I was hoping someone would be able to tell me why this is.

Thanks,
neo
***************
**** HTML *****
***************
<div id="promo-section">
            	<div id="promo-left">
                	<div id="left-top">
                    	<a href="#"><img class="promo-img" src="images/homepage/promo1.jpg" /></a>
                        <div class="promo-info">
                        	<h3>New Fall Styles</h3>
                            <p>Kick your style up a notch. Check out he new fall collection.</p>
                            <h4>Shop <a href="#">Men's New Arrivals</a></h4>
                            <h4>Shop <a href="#">Women's New Arrivals</a></h4>
                        </div>           
                    </div>
                    <div id="left-bottom">
                    	<a href="#"><img class="promo-img" src="images/homepage/promo2.jpg" /></a>
                        <div class="promo-info">
                        	<h3>Teva House</h3>
                            <p>Lifetime. Meet your Trip. Enter to win trip for two to the Teva House in Fiji.</p>
                            <h4>Visit <a href="#">the official teva House site</a></h4>
                        </div>                                
                    </div>
                </div>


*******************
****** CSS ********
*******************
/**** PROMO *****/
#promo-section {
	background:url(../images/homepage/bg-promo.jpg) no-repeat 0 0;
	min-height:294px;
	padding:24px 0 10px 20px;;
}

#promo-left {
	float:left;
}

#left-top {
	margin-bottom:30px;
	min-height:120px;
}	

#left-bottom {
	min-height:120px;
}

#promo-right {
	float: right;
    width: 332px;
}

.promo-img {
	float:left;
	margin-right:10px;
}

.promo-img:hover {
	opacity:.4;
	filter:alpha(opacity=40);
}

.promo-info {
    float:right;
    max-width: 300px;	
}

.promo-info h3 {
	margin:0 0 2px 3px;
	color:#00add9;
	font-weight:bold;
	font-size:13pt;
}

.promo-info h4 {
	margin:0 0 2px 3px;
	color:#ffffff;
	font-weight:bold;
	font-size:10pt;
}

.promo-info h4 a {
	color:#00add9;
	text-decoration:none;
}

.promo-info h4 a:hover {
	color:#00add9;
	text-decoration:underline;
}

.promo-info p {
	font-size:8pt;
	margin:0 0 2px 3px;
}

Open in new window

issue.jpg
0
Comment
Question by:Morgan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
9 Comments
 
LVL 40

Expert Comment

by:Gurvinder Pal Singh
ID: 35169753
apparently they are affected by the parent styles
pleases share the css for this
0
 
LVL 1

Author Comment

by:Morgan
ID: 35169832
Thanks for the reply. I was thinking the same thing, but I could not figure out what parent is effecting it. Using firebug did not reveal any issue I could find.

Below is the complete css file.


thanks,
neo
@charset "utf-8";
/*******************************************************************************************************************
* The following is the main layout for all pages
*******************************************************************************************************************/
body {
	background:url(../images/bg/newBG1.jpg) no-repeat scroll 50% 0 #ffffff;
	font-family:Arial, Helvetica, sans-serif;
	margin: 0; 
	padding: 0;
	color:#999999;
}

.wrapper {
	margin:0 auto;
	width:969px;
	text-align:left;
	overflow:hidden;
}

ol, ul {
	list-style:none outside none;
	margin:0;
}

.clear {
	clear:both;
	margin:0;
	padding:0;
}

#layout-top { /* EMPTY - here only for completness */

}

#layout-middle { /* EMPTY - here only for completness */

}

#layout-bottom {
	background:url(../images/layout/bg-footer.png) no-repeat scroll 50% 0 transparent;
	min-height:150px;
	margin:0;
}

img {
	border: none;
}

/*********************************************
**********************************************
* Header
**********************************************
*********************************************/
#layout-top .wrapper {
	position:relative;
}

#header {
	background:url(../images/logo/bg-header.jpg) no-repeat scroll 0 0;
	height:80px;
}

/**** LOGO *****/
#logo {
	display:block;
	height:35px;
	width:139px;
	position:absolute;
	left:10px;
	top:10px;
}

#logo h1 {
	position:absolute;
	right:-99999em;
}

/**** SEARCH BAR ******/
#search-bar {
	position:absolute;
	top:8px;
	left:767px;	
}

#search-form {
	background:url(../images/layout/bg-search.jpg) no-repeat scroll 0 0;
	height:21px;
	width:165px;
}

#search-form #search-button {
	background:url(../images/layout/btn-search.jpg) no-repeat scroll 0 0;
	border:medium none;
	cursor:pointer;
	height:21px;
	width:30px;
	margin-left:165px;
}

#search-form #search-field {
	background:none repeat scroll 0 0 transparent;
	outline:none;
	border:0 none;
	color:#8e8e8e;
	font-size:12px;
	margin-left:42px;
	padding:2px;
	width:118px;
	position:absolute;
	top:0;
	left:0; /*for IE browser */
}	

/**** NAV BAR ****/
#nav {
	background:url(../images/nav/bg-nav.jpg) no-repeat scroll 0 0;
	min-height:31px;
	width:970px;
	position:absolute;
	top:49px;
}

.nav-bar {
	font-weight:bold;
	font-size:11pt;
	text-transform:uppercase;
	text-align:left;
	line-height:28px;
}

.nav-cell {
	float:left;
}

.nav-cell:hover {
	background:url(../images/nav/light-blue-hover.jpg) no-repeat scroll 0 0;
}

.nav ol, ul {
	padding-left:0;
}

.nav-cell a {
	color:#ffffff;
	text-decoration:none;
}

.nav-first { /* padding for first cell in list */
	padding:0 20px 0 10px;
} 
	
.nav-divider {
	border-left:1px solid #1f1f1f;
	display:block;
	padding:0 20px;
}

/*********************************************
**********************************************
* MIDDLE / CONTENT AREA
**********************************************
*********************************************/
#img-slider {
	min-height:400px;
	background-color:#172b37;
}

/**** PROMO *****/
#promo-section {
	background:url(../images/homepage/bg-promo.jpg) no-repeat 0 0;
	min-height:294px;
	padding:24px 0 10px 20px;;
}

#promo-left {
	float:left;
}

#left-top {
	margin-bottom:30px;
	min-height:120px;
}	

#left-bottom {
	min-height:120px;
}

#promo-right {
	float: right;
    width: 332px;
}

.promo-img {
	float:left;
	margin-right:10px;
}

.promo-img:hover {
	opacity:.4;
	filter:alpha(opacity=40);
}

.promo-info {
    float:right;
    max-width: 300px;	
}

.promo-info h3 {
	margin:0 0 2px 3px;
	color:#00add9;
	font-weight:bold;
	font-size:13pt;
}

.promo-info h4 {
	margin:0 0 2px 3px;
	color:#ffffff;
	font-weight:bold;
	font-size:10pt;
}

.promo-info h4 a {
	color:#00add9;
	text-decoration:none;
}

.promo-info h4 a:hover {
	color:#00add9;
	text-decoration:underline;
}

.promo-info p {
	font-size:8pt;
	margin:0 0 2px 3px;
}

Open in new window

0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 35169874
These are the three classes involved.  ".promo-info h4 a" changes the color of the links.  It's doing what you're telling it to.
.promo-info h3 {
	margin:0 0 2px 3px;
	color:#00add9;
	font-weight:bold;
	font-size:13pt;
}

.promo-info h4 {
	margin:0 0 2px 3px;
	color:#ffffff;
	font-weight:bold;
	font-size:10pt;
}

.promo-info h4 a {
	color:#00add9;
	text-decoration:none;
}

Open in new window

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:Morgan
ID: 35169959
Davebaldwin:

Errr, you may need to re-read my issue. The color is not the problem.

Thanks,
Neo
0
 
LVL 84

Accepted Solution

by:
Dave Baldwin earned 2000 total points
ID: 35169984
Sorry.  You need to set a fixed width.  The second line in the top section (Kick your style...) doesn't take up a full 300px so that div is only 290px wide.  The second line in the bottom section is more than 300px so it takes up the full 300px and wraps.
0
 
LVL 1

Author Comment

by:Morgan
ID: 35170061
Davebaldwin:

Thanks for the reply. So what's your recommendation on fixing it? Change the fixed width with in promo-info. What do you mean kick my style?
0
 
LVL 84

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 2000 total points
ID: 35170276
"Kick your style..." is the first part of the text in the short line.  I changed the CSS for "promo-info" to "width:300px;" from "max-width:300px;" and then they lined up on the left side.
0
 
LVL 1

Author Comment

by:Morgan
ID: 35172485
That did the trick. Thanks!
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 35172503
You're welcome.  Thanks for the points.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When writing CSS, there are a few simple rules that will make your life easier.    1. Using ‘* {box-sizing:border-box;}’. Using this will wrap all your elements in a nice little compact box-model that will give you the width you want, like so... …
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
In this Micro Tutorial viewers will learn how to create a CSS image sprite (In a later tutorial, viewers will learn how to use CSS and HTML to create a navigation menu using this sprite) Open a new Photoshop document with a width of (Icon width)x(N…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses
Course of the Month11 days, 22 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question