CSS Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignCSS Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 2nd, 2008, 04:05 PM
gsquare567 gsquare567 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2007
Posts: 394 gsquare567 User rank is Sergeant (500 - 2000 Reputation Level)gsquare567 User rank is Sergeant (500 - 2000 Reputation Level)gsquare567 User rank is Sergeant (500 - 2000 Reputation Level)gsquare567 User rank is Sergeant (500 - 2000 Reputation Level)gsquare567 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Day 17 h 34 m 38 sec
Reputation Power: 11
Gamebox: image with valign middle but floating? anchored div?

i want to have organized game boxes. the way i want it organized is for the image to be on the left, and the text to the right of the image.

however, i want the image to be in the vertical middle of the div and the text to also be in the vertical middle.

the problem with what i have now is that the image is always at the top of the game box div and so is the text.

ALSO, i want the WHOLE GAMEBOX to act as an <a>, and not just the image and the game title. is that possible?

Code:
if ($a == 2) {
				echo "
			<div class='gamebox clearboth floatleft halfwidth'>";
				$a = 0;
			} else {
				echo "
			<div class='gamebox floatleft halfwidth'>";
			}
			$a++;
			
			$game['desc'] = str_replace("&#039", "'", $game['desc']);
			$game['desc'] = "<span class='gdesc'>".$game['desc']."</span>";
		
			$link = get_game_link("id="._sp($game['id']));
			echo "<a href='".$link."' class='gamelink'>";
			// display game
				echo "
				<div class='floatleft'>
					
						<img src='[imgdir]".$game['nameid'].".png' alt='Play ".$game['name'].
							"' title='Play ".$game['name']."' class='gamethumb' />
					
				</div>
				
				<div class='floatleft wordwrap' style='width:75%'>
					<h3 class='nomargins'><a href='".$link."' class='gamelink'>".$game['name']."</a></h3>";
					
					$rating = round($game['rating']/2);
					echo "
					<img class='nomargins' style='border: 0px' src='[themedir]/ratings/".$rating."stars.gif' alt='".$game['name']." Rating' />";
			
			
					echo "
					<p class='nomargins'>".html_entity_decode($game['desc'], ENT_QUOTES);
					
					if (theme_is_admin()) {
						echo "<small>";
						echo theme_admin_link("Manage Games", "darklink", "games", "manage");
						echo " - ";
						echo theme_admin_link("Edit This Game", "darklink", "games", "editgame-form", "id=".$game['id']);
						echo "</small>";
					}
				
			
			echo "
					</p>
				</div>
				</a>
			</div>";
__________________

Reply With Quote
  #2  
Old May 2nd, 2008, 04:14 PM
Kravvitz's Avatar
Kravvitz Kravvitz is offline
CSS & JS/DOM Adept
Click here for more information.
 
Join Date: Jul 2004
Location: USA
Posts: 15,809 Kravvitz User rank is General 7th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 7th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 7th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 7th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 7th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 7th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 7th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 7th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 7th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 7th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 7th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 7th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 7th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 7th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 7th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 7th Grade (Above 100000 Reputation Level) 
Time spent in forums: 3 Months 3 Weeks 3 Days 14 h 36 m 54 sec
Reputation Power: 1477
__________________
Spreading knowledge, one newbie at a time.

Learn CSS. | PHP includes | X/HTML Validator | CSS validator | Dynamic Site Solutions

IE7: the generation 7 browser new in a world of generation 8 browsers.
Design/program for Firefox (and/or Opera), apply fixes for IE, not the other way around.

Reply With Quote
  #3  
Old May 3rd, 2008, 02:33 AM
gsquare567 gsquare567 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2007
Posts: 394 gsquare567 User rank is Sergeant (500 - 2000 Reputation Level)gsquare567 User rank is Sergeant (500 - 2000 Reputation Level)gsquare567 User rank is Sergeant (500 - 2000 Reputation Level)gsquare567 User rank is Sergeant (500 - 2000 Reputation Level)gsquare567 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Day 17 h 34 m 38 sec
Reputation Power: 11
still doesnt work. can you be more specific, because the links there recommended i use 3 nested divs. is that not a bit much???

Code:
if ($a == 2) {
				echo "
			<div class='gamebox clearboth floatleft halfwidth'>";
				$a = 0;
			} else {
				echo "
			<div class='gamebox floatleft halfwidth'>";
			}
			$a++;
			
			$game['desc'] = str_replace("&#039", "'", $game['desc']);
		
			$link = get_game_link("id="._sp($game['id']));
			echo "<a href='".$link."' class='gamelink'>";
			// display game
				echo "
				<div class='floatleft'>
					
						<img src='[imgdir]".$game['nameid'].".png' alt='Play ".$game['name'].
							"' title='Play ".$game['name']."' class='gamethumb' />
					
				</div>
				
				<div class='floatleft wordwrap' style='width:75%'>
					<h3 class='nomargins'><a href='".$link."' class='gamelink'>".$game['name']."</a></h3>";
					
					$rating = round($game['rating']/2);
					echo "
					<img class='nomargins' style='border: 0px' src='[themedir]/ratings/".$rating."stars.gif' alt='".$game['name']." Rating' />";
			
			
					echo "
					<p class='nomargins'>".html_entity_decode($game['desc'], ENT_QUOTES);
					
					if (theme_is_admin()) {
						echo "<small>";
						echo theme_admin_link("Manage Games", "darklink", "games", "manage");
						echo " - ";
						echo theme_admin_link("Edit This Game", "darklink", "games", "editgame-form", "id=".$game['id']);
						echo "</small>";
					}
				
			
			echo "
					</p>
				</div>
				</a>
			</div>";


CSS:
Code:
div.gamebox {
	padding-top:4px;
	padding-bottom:4px;
	overflow: hidden;
	position: relative;
}

div.gamebox[id] {
	display: table;
	position: static;
}

div.gamebox a {
	color:black;
}

div.gamebox a:hover {
	color:#495B20;
}


and for my second question, about the whole div being an anchor? i tried putting href in div and i've tried the anchor surrounding the div, but nope.

Reply With Quote
  #4  
Old May 3rd, 2008, 06:38 AM
essee essee is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2008
Posts: 94 essee User rank is Sergeant Major (2000 - 5000 Reputation Level)essee User rank is Sergeant Major (2000 - 5000 Reputation Level)essee User rank is Sergeant Major (2000 - 5000 Reputation Level)essee User rank is Sergeant Major (2000 - 5000 Reputation Level)essee User rank is Sergeant Major (2000 - 5000 Reputation Level)essee User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Days 19 h 23 m 49 sec
Reputation Power: 21
Quote:
the links there recommended i use 3 nested divs. is that not a bit much???

Yes. Yes it is. But CSS is is often still one of those things where you have to work with what your given. Go through it again it should work.

As for your second question. You can't nest a <div> inside an <a> or more specifically a block level element inside an inline element. What you need to do is forget the div and use an appropriate tag. In this case the anchor tag <a>. Make it display:block and use that as your container. Something like this-

Code:
<a href="blah" class="blah"><img src="blahblah" class="blahblah" />Some text here that will display on the right of the img</a>

Reply With Quote
  #5  
Old May 4th, 2008, 06:27 PM
gsquare567 gsquare567 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2007
Posts: 394 gsquare567 User rank is Sergeant (500 - 2000 Reputation Level)gsquare567 User rank is Sergeant (500 - 2000 Reputation Level)gsquare567 User rank is Sergeant (500 - 2000 Reputation Level)gsquare567 User rank is Sergeant (500 - 2000 Reputation Level)gsquare567 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Day 17 h 34 m 38 sec
Reputation Power: 11
sum1 please help, this just isnt working. no example is what i want, and trying to fit it is like watching Hannibul.

css:
Code:
.outer {height:100;overflow: hidden; position: relative; width:50%;}
.outer[id] {display: table; position: static;}

.middle {position: absolute; top: 50%;} 
.middle[id] {display: table-cell; vertical-align: middle; position: static;}

.inner {display: block; position: relative; top: -50%; overflow: hidden;} 


html
Code:
// display game boxes		
		foreach ($games as $game) {
			if ($a == 2) {
				echo "
			<div class='outer floatleft clearboth halfwidth'>";
				$a = 0;
			} else {
				echo "
			<div class='outer floatleft halfwidth'>";
			}
				echo "<div class='middle'>";
			$a++;
			
			$game['desc'] = str_replace("&#039", "'", $game['desc']);
		
			$link = get_game_link("id="._sp($game['id']));
			echo "<a href='".$link."' class='inner'>";
			// display game
				echo "
				<div class='floatleft'>
					
						<img src='[imgdir]".$game['nameid'].".png' alt='Play ".$game['name'].
							"' title='Play ".$game['name']."' class='gamethumb' />
					
				</div>
				
				<div class='wordwrap floatleft' style='width:75%'>
					<h3 class='nomargins'><a href='".$link."' class='gamelink'>".$game['name']."</a></h3>";
					
					$rating = round($game['rating']/2);
					echo "
					<img class='nomargins' style='border: 0px' src='[themedir]/ratings/".$rating."stars.gif' alt='".$game['name']." Rating' />";
			
			
					echo "
					<p class='nomargins'>".html_entity_decode($game['desc'], ENT_QUOTES);
					
					if (theme_is_admin()) {
						echo "<small>";
						echo theme_admin_link("Manage Games", "darklink", "games", "manage");
						echo " - ";
						echo theme_admin_link("Edit This Game", "darklink", "games", "editgame-form", "id=".$game['id']);
						echo "</small>";
					}
				
			
			echo "
					</p>
				</div>
			</a></div></div>";


i use the inner as an anchor because it is allowed to be a block. why is there so much room above every gamebox?
http://www.viportals.com/category/all/1/

Reply With Quote
  #6  
Old May 6th, 2008, 03:12 PM
gsquare567 gsquare567 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2007
Posts: 394 gsquare567 User rank is Sergeant (500 - 2000 Reputation Level)gsquare567 User rank is Sergeant (500 - 2000 Reputation Level)gsquare567 User rank is Sergeant (500 - 2000 Reputation Level)gsquare567 User rank is Sergeant (500 - 2000 Reputation Level)gsquare567 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Day 17 h 34 m 38 sec
Reputation Power: 11
btw,

Code:
.outer {height:100;overflow: hidden; position: relative; width:50%;}
.outer[id] {display: table; position: static;}

.middle {position: absolute; top: 50%;} 
.middle[id] {display: table-cell; vertical-align: middle; position: static;}

.inner {display: block; position: relative; top: -50%; overflow: hidden;} 


what is "[id]"

Reply With Quote
  #7  
Old May 6th, 2008, 03:17 PM
Kravvitz's Avatar
Kravvitz Kravvitz is offline
CSS & JS/DOM Adept
Click here for more information.
 
Join Date: Jul 2004
Location: USA
Posts: 15,809 Kravvitz User rank is General 7th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 7th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 7th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 7th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 7th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 7th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 7th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 7th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 7th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 7th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 7th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 7th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 7th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 7th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 7th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 7th Grade (Above 100000 Reputation Level) 
Time spent in forums: 3 Months 3 Weeks 3 Days 14 h 36 m 54 sec
Reputation Power: 1477
I'm not sure why it isn't working.

The "[id]" is an attribute selector. In this case it means that the rule should be applied if the element belonging to the "middle" class has an ID. It's one way to hide a style rule from IE5-6.

Reply With Quote
  #8  
Old May 6th, 2008, 05:17 PM
gsquare567 gsquare567 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2007
Posts: 394 gsquare567 User rank is Sergeant (500 - 2000 Reputation Level)gsquare567 User rank is Sergeant (500 - 2000 Reputation Level)gsquare567 User rank is Sergeant (500 - 2000 Reputation Level)gsquare567 User rank is Sergeant (500 - 2000 Reputation Level)gsquare567 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Day 17 h 34 m 38 sec
Reputation Power: 11
i'll try starting with the basics that ffx understands, the table-cell method:
Code:
.outer {display: table;}
.middle {display: table-cell; vertical-align: middle;}


and i'll just make it a div for now. brb =)

Reply With Quote
  #9  
Old May 6th, 2008, 06:54 PM
gsquare567 gsquare567 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2007
Posts: 394 gsquare567 User rank is Sergeant (500 - 2000 Reputation Level)gsquare567 User rank is Sergeant (500 - 2000 Reputation Level)gsquare567 User rank is Sergeant (500 - 2000 Reputation Level)gsquare567 User rank is Sergeant (500 - 2000 Reputation Level)gsquare567 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Day 17 h 34 m 38 sec
Reputation Power: 11
im having one last problem. i outlined it and found the problem from before; i needed different inner divs.

now my problems are:

1) the image is not centered
2) the heights of the outer divs are not the same, even though i clearly say 65px

HTML:
Code:
<div class='gamebox_outer floatleft clearboth halfwidth'>";
				$a = 0;
			} else {
				echo "
			<div class='gamebox_outer floatleft halfwidth'>";
			}

			$a++;
			
			$game['desc'] = str_replace("&#039", "'", $game['desc']);
		
			$link = get_game_link("id="._sp($game['id']));
			
			// display game
				echo "
				<div class='gamebox_inner gamethumbbox'>
					<img src='[imgdir]".$game['nameid'].".png' alt='Play ".$game['name'].
						"' title='Play ".$game['name']."' class='gamethumb' />
				</div>
				
				<div class='gamebox_inner gamedescbox'>
					<div class='gamedesc'>
						<h3 class='nomargins'><a href='".$link."' class='gamelink'>".$game['name']."</a></h3>";
						
						$rating = round($game['rating']/2);
						echo "
						<img class='nomargins' style='border: 0px' src='[themedir]/ratings/".$rating."stars.gif' alt='".$game['name']." Rating' />";
				
				
						echo "
						<p class='nomargins'>".html_entity_decode($game['desc'], ENT_QUOTES);
						
						if (theme_is_admin()) {
							echo "<small>";
							echo theme_admin_link("Manage Games", "darklink", "games", "manage");
							echo " - ";
							echo theme_admin_link("Edit This Game", "darklink", "games", "editgame-form", "id=".$game['id']);
							echo "</small>";
						}
					
				
				echo "
						</p>
					</div>
				</div>
			</div>";


CSS:
Code:
.gamebox_outer {border: 1px solid blue; overflow: hidden; display: table; position: static;}

	.gamebox_outer .gamebox_inner {border: 1px solid red; overflow: hidden; display: table-cell; vertical-align: middle; position: static; height:65px} 
	
	.gamebox_outer .gamethumbbox{
		width:80px;
		height:65px;
	} 
	
	.gamebox_outer .gamedescbox{
		overflow: hidden;
		height:65px;
	}



EDIT: thanks to Kravvitz's teachings, i remembered about margins and paddings, so i answered my first question. to make the image centered, i added
Code:
margin:0;
		padding:0;
		text-align:center;
to .gamethumbbox and it works swell.

my first question still stands

Last edited by gsquare567 : May 6th, 2008 at 07:18 PM.

Reply With Quote
  #10  
Old May 6th, 2008, 11:34 PM
Kravvitz's Avatar
Kravvitz Kravvitz is offline
CSS & JS/DOM Adept
Click here for more information.
 
Join Date: Jul 2004
Location: USA
Posts: 15,809 Kravvitz User rank is General 7th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 7th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 7th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 7th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 7th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 7th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 7th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 7th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 7th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 7th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 7th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 7th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 7th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 7th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 7th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 7th Grade (Above 100000 Reputation Level) 
Time spent in forums: 3 Months 3 Weeks 3 Days 14 h 36 m 54 sec
Reputation Power: 1477
Don't you mean your second question?

Anyway, the height of ".gamebox .outer" is less than its parent's. The simplest fix would be to set them to the same thing.

Thought about just giving ".gamebox" display:table? Do you intend to use ".outer" for anything else?

Reply With Quote
  #11  
Old May 7th, 2008, 10:04 AM
gsquare567 gsquare567 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2007
Posts: 394 gsquare567 User rank is Sergeant (500 - 2000 Reputation Level)gsquare567 User rank is Sergeant (500 - 2000 Reputation Level)gsquare567 User rank is Sergeant (500 - 2000 Reputation Level)gsquare567 User rank is Sergeant (500 - 2000 Reputation Level)gsquare567 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Day 17 h 34 m 38 sec
Reputation Power: 11
Question

Quote:
Originally Posted by Kravvitz
Don't you mean your second question?

Anyway, the height of ".gamebox .outer" is less than its parent's. The simplest fix would be to set them to the same thing.

Thought about just giving ".gamebox" display:table? Do you intend to use ".outer" for anything else?


well remember how i was trying to set it up so the whole gamebox div can be an <a> that gets a background on hover.

and it did not work if i did not surround it with the gamebox class, it goes gamebox-> outer-> inner, and i want the whole gamebox to be an <a>nchor with href to the game. i tried chaning it to a.gamebox last night but it ****ed up the whole thing

any ideas on converting it (this will be my new 1st question)?

Last edited by gsquare567 : May 7th, 2008 at 10:07 AM.

Reply With Quote
  #12  
Old May 7th, 2008, 11:25 AM
Kravvitz's Avatar
Kravvitz Kravvitz is offline
CSS & JS/DOM Adept
Click here for more information.
 
Join Date: Jul 2004
Location: USA
Posts: 15,809 Kravvitz User rank is General 7th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 7th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 7th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 7th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 7th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 7th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 7th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 7th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 7th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 7th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 7th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 7th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 7th Grade (Above 100000 Reputation Level)