473,387 Members | 1,876 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Neither div nor span aligning within container div

Hi,

I have a container div, which contains two divs, which need to appear side by side. Everything is fixed width, but the two divs are appearing with a line break. I tried to fix this by converting them into spans, but even then they appeared with a line break.

The style sheet properties for these are

Expand|Select|Wrap|Line Numbers
  1. #container{
  2.     width:992px;
  3.     background-image:url(../images/content_background.png);
  4.     background-repeat:repeat-y;
  5.     padding-top:27px;
  6.     margin-left:auto;
  7.     margin-right:auto;
  8. }
  9.  
  10. #div1{
  11.     width:45.31em;
  12.     margin-left:2.31em;
  13.     margin-bottom:0.94em;
  14. }
  15.  
  16. #skyscraper160x600{
  17.     width:10.00em;
  18.     height:37.75em;
  19.     margin-right:27px;
  20. }
  21.  
  22.  
I have tried everything, such as setting float properties for the two, display:inline for #container, but nothing works. Can some one please tell me how to fix this.
Jan 8 '11 #1
4 3352
Dormilich
8,658 Expert Mod 8TB
display: inline; or float should have worked. the only thing preventing that (I can imagine) is that the width of the two divs is too large (you define 992px for the parent and 57.62em*+27px for both divs, that’s absolute vs. relative units)

if 1em* exceeds 16.7px the divs won’t fit

*- roughly the size of 00 or the letter M
Jan 8 '11 #2
AutumnsDecay
170 100+
div1 should have float:left
skyscraper should have float:right

Try this, and give your divs a pixel amount for the width to ensure they're not too large for the containing div. Even doing a test of 400px in width for both, with float left and float right respectively on each child div, should give you some results.
Jan 8 '11 #3
drhowarddrfine
7,435 Expert 4TB
if 1em* exceeds 16.7px the divs won’t fit

*- roughly the size of 00 or the letter M
'Tis not. On the web, 1em is equal to the current font size. If the current font size is 16px, then 1em=16px.
Jan 8 '11 #4
Hi,

Thanks guys for your response..I fixed it by removing the #container all together...as #container was wrapped inside #containerwrap, I just included a clear:both in #containerwrap, and made #div1 float:left, and #skyscraper float:right. That seems to have fixed it...I still did not understand why the floats were being ignored when the two divs were inside #container..thanks again..:)
Jan 9 '11 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: C | last post by:
Hi, I have a link on an asp page. When the user clicks on this link I make a <span> visible. Within my span I have a series of textboxes. In Netscape 6.0 and 7.0 these textboxes are...
3
by: Simon Wigzell | last post by:
My page here : http://www.gabriolaisland.org/GICC/bedBreakfast.htm is produced from a database with asp, no problem. The client is very picky - he wants all the text boxes to be the same size and...
3
by: T | last post by:
I am attempting to create a menu using <div> and <span> tags within a table cell. When the page loads, some of the classes don't seem to be applied. If I hover over the menu everything is fine...
5
by: Tony | last post by:
I seem to be missing something in my understanding. If I leave off absolute positioning, shouldn't nested DIV/SPAN be displayed inside the parent, and ones outside that display separately? Here...
2
by: jez123456 | last post by:
Hi. I have a web form with a datagrid that displays employees who are on holiday. One of the datagrid columns shows the date of their last day of holiday, but what I really require is the Start Back...
4
by: C | last post by:
Hi, I have a link on an aspx page. When the user clicks on this link I make a <span> visible. Within my span I have a series of textboxes. In Netscape 6.0 and 7.0 these textboxes are...
1
by: Doug | last post by:
The html below shows DataList "DiscountList" nested within DataList "EventItemList". DiscountList contains a Label control. I'm trying to find the label, using FindControl, during...
26
by: johkar | last post by:
I need to cancel the link and execute a function onclick of all the links within the span tag which has a class of "container" assigned. There will be only one span tag with this class applied. ...
6
by: lilOlMe | last post by:
Hi there! I'm having a problem with a <span> element's width. I have a span element within a div block: <div class="picker"> <span id="ctl00_cph_mainContent_TPKR_Tues_LBL_TitleForPicker"...
14
by: gaijinco | last post by:
I was a hobbist web coder for years but I had to sidestep for a while. Now I'm trying to return to it and I'm trying to clarify how am I supposed to do somethings with CSS v.s. HTML and I'm...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.