OutFront Forums
     Home    Register     Search      Help      Login    

Follow Us
On Facebook
On Twitter
RSS
Via Email

Recent Posts
Todays Posts
Most Active posts
Posts since last visit
My Recent Posts
Mark posts read

Sponsors
Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.
Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.
Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

 

Two elements on same line

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> Cascading Style Sheets and Accessibility >> Two elements on same line
Page: [1]
 
DaveX

 

Posts: 230
Joined: 5/4/2004
Status: offline

 
Two elements on same line - 7/17/2008 11:58:26   
One thing I'm having a hard time with in CSS is the positioning rules. For instance, I've got two named elements at the top of my page one right under the other and then an "<hr>" under those. I want to put them both right above the line with one all the way to the left and one all the way to the right. I've played around with both relative and absolute positioning without much luck. Do I need to figure in percentages here?
TexasWebDevelopers

 

Posts: 722
Joined: 2/22/2002
From: Dallas, TX
Status: offline

 
RE: Two elements on same line - 7/17/2008 14:32:53   
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>css test</title>
<style type="text/css">
<!--
body {
font: 100% Verdana, Arial, Helvetica, sans-serif;
background: #666666;
margin: 0; /* it's good practice to zero the margin and padding of the body element to account for differing browser defaults */
padding: 0;
text-align: center; /* this centers the container in IE 5* browsers. The text is then set to the left aligned default in the #container selector */
color: #000000;
}
.wrapper #container {
width: 780px; /* using 20px less than a full 800px width allows for browser chrome and avoids a horizontal scroll bar */
background: #FFFFFF;
margin: 0 auto; /* the auto margins (in conjunction with a width) center the page */
border: 1px solid #000000;
text-align: left; /* this overrides the text-align: center on the body element. */
}
.wrapper #sidebar_right {
float: right; /* since this element is floated, a width must be given */
width: 360px; /* the actual width of this div, in standards-compliant browsers, or standards mode in Internet Explorer will include the padding and border in addition to the width */
background: #EBEBEB;
}
.wrapper #sidebar_left {
margin-top: 0;
margin-right: 380px;
margin-bottom: 0;
margin-left: 0;
padding-top: 0;
padding-right: 20px;
padding-bottom: 0;
padding-left: 20px;
}
.fltrt { /* this class can be used to float an element right in your page. The floated element must precede the element it should be next to on the page. */
float: right;
margin-left: 8px;
}
.fltlft { /* this class can be used to float an element left in your page */
float: left;
margin-right: 8px;
}
.clearfloat { /* this class should be placed on a div or break element and should be the final element before the close of a container that should fully contain a float */
clear:both;
height:0;
font-size: 1px;
line-height: 0px;
}
-->
</style>
<!--[if IE 5]>
<style type="text/css">
/* place css box model fixes for IE 5* in this conditional comment */
.wrapper #sidebar_right { width: 220px; }
</style>
<![endif]--><!--[if IE]>
<style type="text/css">
/* place css fixes for all versions of IE in this conditional comment */
.wrapper #sidebar_right { padding-top: 30px; }
.wrapper #sidebar_left { zoom: 1; }
/* the above proprietary zoom property gives IE the hasLayout it needs to avoid several bugs */
</style>
<![endif]--></head>

<body class="wrapper">

<div id="container">
<div id="sidebar_right">
<h3>Sidebar right Content</h3>
<!-- end #sidebar_right --></div>
<div id="sidebar_left">
<h3>Sidebar left Content</h3>
<!-- end #sidebar_left --></div>
<!-- This clearing element should immediately follow the #sidebar_left div in order to force the #container div to contain all child floats --><br class="clearfloat" />
<hr />
<!-- end #container --></div>
</body>
</html>

(in reply to DaveX)
jaybee

 

Posts: 14320
Joined: 10/7/2003
From: Berkshire, UK
Status: offline

 
RE: Two elements on same line - 7/17/2008 15:22:54   
Float element 1 left and element 2 right

In the code:
<p class="element1">ELEMENT 1</p>
<p class="element2">ELEMENT 2</p>
<hr />

in the css

.element1 {float:left;}
.element2 {float:right;}

you might want a div instead of a p, depends on your layout

_____________________________

If it ain't broke..... fix it until it is.
:)

:)
GAWDS
Now where did I put that Doctype?

(in reply to TexasWebDevelopers)
Tailslide

 

Posts: 6692
Joined: 5/10/2005
From: Out here on the raggedy edge
Status: offline

 
RE: Two elements on same line - 7/18/2008 2:33:55   
Plus a width - always add a width to floats unless it's implicit (e.g. images).

_____________________________

Little Blue Plane Web Design | Land Rover project

:)

(in reply to jaybee)
jaybee

 

Posts: 14320
Joined: 10/7/2003
From: Berkshire, UK
Status: offline

 
RE: Two elements on same line - 7/18/2008 5:51:08   
Yep, forgot that bit. I've spent all day floating images :)

_____________________________

If it ain't broke..... fix it until it is.
:)

:)
GAWDS
Now where did I put that Doctype?

(in reply to Tailslide)
Page:   [1]

All Forums >> Web Development >> Cascading Style Sheets and Accessibility >> Two elements on same line
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts