I have a navbar in a div, with several links. The last one is in a <span> because I want it to float to the right by itself. The span does float right, but it shows up below the navbar div. I want it within the div.
Is this doable? Thanks. - <?php
-
-
echo "<p>";
-
echo '<div id="navbar">
-
<a href="edit_reg.php">edit</a>
-
<a href="undelete.php">undelete</a>
-
<a href="print_reg.php">print</a>
-
<a href="rep_sum.php">summary</a>
-
<span style="float: right"><a href="index.php">reg page</a></span>
-
</div><p>';
-
-
?>
7 25825
I guess it's better to post the HTML output rather than just the PHP source: -
<p>
-
<div id="navbar">
-
<a href="edit_reg.php">edit</a>
-
<a href="undelete.php">undelete</a>
-
<a href="print_reg.php">print</a>
-
<a href="rep_sum.php">summary</a>
-
<span style="float: right"><a href="index.php">reg page</a></span>
-
</div>
-
See if this works for you... -
-
CSS
-
#navlist li{
-
display: inline;
-
list-style-type: none;
-
padding-right: 20px;
-
}
-
.c1 {float:right;}
-
-
-
HTML
-
-
<div id="navcontainer">
-
<ul id="navlist">
-
<li><a href="#">Item one</a></li>
-
<li><a href="#">Item two</a></li>
-
<li><a href="#">Item three</a></li>
-
<li><a href="#">Item four</a></li>
-
<li class="c1"><a href="#">Item five</a></li>
-
</ul>
-
</div>
-
-
-
-
Thanks, David. Unfortunately, that similarly drops down the right-floated item (in IE7 and FF2).
I guess I'll have to live with it... or use a table.
Sorry. My bad!
Same HTML as in previous example with this CSS: -
html, body {margin:0;padding:0;}
-
body {
-
font : 100% arial, sans-serif;
-
}
-
#navcontainer ul{
-
margin:0;
-
padding: 0;
-
}
-
-
#navlist li{
-
float:left;
-
padding-right:20px;
-
display: inline;
-
list-style-type: none;
-
}
-
.c1 {position:absolute;top: 0; right: 20px;}
-
Quick checked in IE/6, IE/7, Win FF/2.0.0.14, Mac FF3.0.1, Mac Safari, Mac Opera.
okay, thanks for conveying the concept of absolute positioning
I would have to fine tune the location by pixels, to match
Although it shows up "below", it is still part of your navbar DIV.
The solution is very simple. You need to do your floats first (both left and right) followed by your "middle bits".
If you move <span style="float: right">... from the end of the navbar DIV to the beginning of the DIV, then everything fits on one line the way you want.
Think of it this way: You can't introduce FLOAT content which causes previously-rendered content to be pushed out of the way.
Hi,
Try to this html and css code - <style="text/css">
-
-
#navlist li{
-
display: inline;
-
list-style-type: none;
-
padding-right: 20px;
-
}
-
.c1 {float:right;}
-
-
</style>
-
</head>
-
<body>
-
-
<div id="navcontainer">
-
<ul id="navlist">
-
<li><a href="undelete.php">undelete</a></li>
-
<li><a href="print_reg.php">print</a></li>
-
<li><a href="rep_sum.php">summary</a></li>
-
<li class="c1"><a href="index.php">reg page</a></li>
-
</ul>
-
</div>
-
</body>
-
</html>
-
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: JKenyon |
last post by:
I am attempting to display two images on a web page. The second
"image" is actually two images, one overlaid on the other. The first
one is aligned on the left using float:left. I have enclosed the next
two images in a <DIV> tag with float: right in order to force the
containing content to be aligned on the right. I also set
position:relative so that any absolute positioning within the <DIV>
will be relative to the itself.
The...
|
by: leegold |
last post by:
Why does float:right cause a line break? Try the code below. Is there a
fix? I want the link on the same line as the text. Thanks
<html>
<head>
<STYLE>
span.linkpos { float:right; clear: none; color:blue; }
</style>
</head>
|
by: Michael Shell |
last post by:
Greetings,
I've been playing with CSS inline floats of <span> elements and the
results are not quite what I would expect. In the example attached
at the end of this post, I would expect the floated span 2 to be
on the same line as span 1, but instead it is on the same line
as span 3, which is on the line below span 1. Eric Meyer's CSS
pocket reference gives a clue as to why this is so: "A floated
element will generate a block-level box...
|
by: Oliver Block |
last post by:
Hello everybody,
I wonder why a
<span style="float:right">some text</span>
might be displayed out of a surrounding div element. It is shifted to the
next line.
I thougt it is supposed to appear inside the surrounding div. There is
|
by: ashkaan57 |
last post by:
Hi,
I am trying to put text on left and right side of the page and used:
<div>
<span>blah blah</span>
<span style="float:right">blah blah</span>
</div>
The 2nd text does go to the right but the next line. What am I doing
wrong?
TIA.
| |
by: bogdan |
last post by:
Hi,
I have a div to provide a background image for a menu. I'd like to position
the menu on the right side but I can't seem to find a right way of doing it.
The only way the menu will move to the right if I set text-align=right in
the div. The problem is that menu items are then also aligned on right
side. Not only that but this alignment works only in IE.
Could someone please let me know how to right-align the menu?
|
by: paragpdoke |
last post by:
Hello All.
I have a weird observation regarding the CSS float style for span.
Allow me to share details before asking my question:
Screen resolution: 1024x768 (I know my monitor is outdated; it can't display higher than this)
Link: http://www.w3schools.com/js/tryit.asp?filename=try_dom_style_cssfloat
Text entered in the left side:
<html>
<body>
|
by: luftikus143 |
last post by:
Hi there,
I am building a small WebApp, and using a list to display country values for a specific variable. It should be like
Country A 10
Country B 4
Country C 125
So, what I have in CSS is this:
|
by: Chinsu |
last post by:
<html>
<head>
<style>
#ex {
width: 700px;
background: red;
float: left;
}
a, span {
display: block;
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |