Jump to content

Trouble with floating CSS


Noskiw

Recommended Posts

I'm currently in the middle of rewriting my website and have run into a little trouble.

 

When floating the unordered list to the right, the span no longer displays inline, despite having the unordered list's display to "inline".

 

Here's an image to show you what I mean:

 

3663ab4d49ce7749368e527dad9765ae.png

Here's the markup:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
	
	<head>

		<title>Matthew Noskiw's website</title>

		<link rel='stylesheet' type='text/css' href='./inc/CSS/styles/default.css' />
		<link rel='stylesheet' type='text/css' href='./inc/CSS/static/navigation.css' />

	</head>

	<body>

		<div id='Container'>

			<div id='Header'>

				<div style='float: right'>

					<ul id='Navigation'>

						<li id='NavButton' class='active'><a href='./'>Home</a></li>
						<li id='NavButton'><a href='./about'>About</a></li>
						<li id='NavButton'><a href='./blog'>Blog</a></li>
						<li id='NavButton'><a href='./contact'>Contact</a></li>

					</ul>

				</div>

				<span>noskiw.co.uk</span>

			</div>

		</div>

	</body>

</html>

Specifically, this section:

		<div id='Container'>

			<div id='Header'>

				<div style='float: right'>

					<ul id='Navigation'>

						<li id='NavButton' class='active'><a href='./'>Home</a></li>
						<li id='NavButton'><a href='./about'>About</a></li>
						<li id='NavButton'><a href='./blog'>Blog</a></li>
						<li id='NavButton'><a href='./contact'>Contact</a></li>

					</ul>

				</div>

				<span>noskiw.co.uk</span>

			</div>

		</div>

And here is the CSS:

body
{
	font-family: arial;
	font-size: 14px;
	color: #000000;
}

#Container
{
	width: 800px;
	border: 1px solid #000000;
	margin: 0 auto;
	padding: 3px;
}

#Header
{
	overflow: hidden;
	border: 1px solid #000000;
	padding: 5px;
}

Any help will be appreciated, thanks.

Link to comment
https://forums.phpfreaks.com/topic/290199-trouble-with-floating-css/
Share on other sites

Also thought that this may be relevant, the navigation CSS file:

#Navigation
{
	display: inline;
	list-style-type: none;
}

#NavButton
{
	display: inline-block;
	width: 70px;
	margin-left: 3px;
	-webkit-border-radius: 5px;
	-moz-border-radius: 5px;
	border-radius: 5px;
}

#NavButton a
{
	text-align: center;
	display: block;
	padding: 6px;
	color: #000000;
	text-decoration: none;
	font-weight: bold;
}

#NavButton a:hover
{
	-webkit-border-radius: 5px;
	-moz-border-radius: 5px;
	border-radius: 5px;
	background-color: #E8E8EE;
}

.active
{
	background-color: #1C75D4;
}

.active a
{
	color: #FFFFFF !important;
}

.active a:hover
{
	background-color: #1C75D4 !important;
}

It would like it to be perfectly in line with the unordered list. I know it must be slightly tedious, but I'm unfortunately one of those guys who is bothered by stuff like this.

 

The address definitely looks more professional when it's centered vertically. You could convert the <span> tag into an inline block and add some margins.

#Header span
{
     display: inline-block;
     margin: 6px;  /* <-- same as the padding for #NavButton a */
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.