Solved

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

Posted on 2011-03-18
9
239 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
  • 4
  • 4
9 Comments
 
LVL 40

Expert Comment

by:gurvinder372
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 83

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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 500 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 83

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 500 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 83

Expert Comment

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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how to create a tile layout 1 39
Urgent Help with HTML CSS Positioning 9 43
Re-position the objects 7 98
CSS Question 5 42
So you have coded your own WordPress plugin and now you want to allow users to upload images to a folder in the plugin folder rather than the default media location? Follow along and this article will show you how to do just that!
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

864 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now