Jump to content

CSS display issue.


williamZanelli

Recommended Posts

Hey guys,

 

I'm trying to achieve something relativly simple.

 

I have a menu bar, across the top of my webpage, I want the logo to be on the left, and the text to be on the right,

 

This i can achieve via float.

 

The problem is I want the text to be at the bottom of the block and not the top.. any ideas on how I can achieve this?

 

Thanks in advance for your thoughst, my code is below

 

<!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=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">

#wrap{
width: 990px;
margin: 0 auto;
border: #CCCCCC 1px;
border-style: solid; 

}

#top_banner {
width: 725px;
margin: 0 auto;

}
#logo img{
height: 100px;
width: 200px; 
float:left;
}
#topMenu ul li{
float:right;
padding-right: 20px;
list-style:none;
display: inline;
text-decoration: none;
border: solid 2px #FF0000;

}
#topMenu {
display:block;
}

#top_bar{
border-top: solid 2px #999999;
display:block;
}

  body {
    color: purple;

    /*background-color: #d8da3d */}

</style>

</head>


<body>

<div id="wrap">
<div id="top_banner">
<img src="images/aa banner.jpg" />
</div>
<div id="top_bar">
<div id="logo">
<img src="images/txt_logo.jpg" />
</div>
<div id="topMenu">
<ul>
<li>item1</li>
<li>item2</li>
<li>item3</li>
</ul>
</div>
</div>

</div>

</body>
</html>

Link to comment
Share on other sites

Thanks for the message LoneWolf

 

I've tried your suggestion, but still cant get iut right, here's my code, simplified. Where am I going wrong?!  ??? ???

 

i'm pretty sure it's an issue with vertical-aligh.

 

<!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=iso-8859-1" />
<title>Untitled Document</title>

<style type="text/css">

  
#logo img{
height: 100px;
width: 200px; 
float:left;
}

#topMenu ul li{
float:right;
padding-right: 20px;
list-style:none;

text-decoration: none;
border: solid 2px #FF0000;
font-weight:bold;

}
#topMenu {
vertical-align:bottom;
}

</style>

</head>

<body>

<div id="top_bar">
<div id="logo" >
<img src="images/txt_logo.jpg" />
</div>
<div id="topMenu"  >
<ul >
<li>item1</li>
<li>item2</li>
<li>item3</li>
</ul>
</div>
</div>
</body>
</html>

Link to comment
Share on other sites

Why not simply use some positioning? Instead of css float?

 

<!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=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
#wrap {
  width: 990px;
  margin: 0 auto;
  border: #CCCCCC 1px;
  border-style: solid; 
}
#top_banner {
  width: 725px;
  margin: 0 auto;
  min-height: 120px;
}
#logo img{
  height: 100px;
  width: 200px; 
  float: left;
}
#topMenu li{
  float: right;
  padding-right: 20px;
  list-style-type: none;
  text-decoration: none;
  border: solid 2px #FF0000;
}
#topMenu {
  position: absolute;
  bottom: 0;
  right: 0;
  clear: both;
  margin: 0;
  padding: 0;
}

#top_bar{
  position: relative;
  border-top: solid 2px #999999;  clear: both;
  min-height: 120px;
}
body {
    color: purple;
}

</style>

</head>


<body>

<div id="wrap">
<div id="top_banner">
<img src="images/aa banner.jpg" />
</div>
<div id="top_bar">
<div id="logo">
<img src="images/txt_logo.jpg" />
</div>
<div id="topMenu">
<ul>
<li>item1</li>
<li>item2</li>
<li>item3</li>
</ul>
</div>
</div>

</div>

</body>
</html>

 

There is no need to apply display: block; to elements that are blocks by default.

 

Also remember to clear your floats, so that the parant dosn't collapse.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.