Solved

css help for div layout required

Posted on 2012-04-11
5
227 Views
Last Modified: 2012-06-22
layout wanted
i'm using this

.wideBox {
  clear: both;
  width: 90%;
  text-align: center;
  margin: 70px;
  padding: 10px;

  background: #FFFFFF;
  border: 1px solid grey;
}

.loginBox {
    width: 20%;
      margin: 70px;
      height: auto;
    float:left; /* add this */
    border: 1px solid grey;
      padding: 10px;
}
.newsBox {
    border: 1px solid grey;
      width: 65%;
    overflow: hidden; /* if you don't want #second to wrap below #first */
      display: block;
      font-size: 1.2em;
      padding: 10px;
}

to try and get the boxes to line up as per the image. it's not happening.
the top one (widebox) is fine.
the bottom 2 i want to be the same size (combined with gap in the middle) as the wide box - and they must be aligned on top.

help please.
0
Comment
Question by:blue-genie
  • 2
  • 2
5 Comments
 
LVL 3

Expert Comment

by:gnemi
Comment Utility
in .loginBox change margin to margin-left

in .newsBox add float: right; and margin-right: 100px;
.wideBox {
  clear: both;
  width: 90%;
  text-align: center;
  margin: 70px;
  padding: 10px;

  background: #FFFFFF;
  border: 1px solid grey;
}

.loginBox {
    width: 20%;
    margin-left: 70px;
    height: auto;
    float:left; /* add this */
    border: 1px solid grey;
    padding: 10px;
}
.newsBox {
    border: 1px solid grey;
    width: 65%;
    overflow: hidden; /* if you don't want #second to wrap below #first */
    display: block;
    font-size: 1.2em;
    padding: 10px;
    float: right;
    margin-right: 100px;
}

Open in new window

0
 
LVL 12

Expert Comment

by:Anuradha Goli
Comment Utility
Try this code it might help you resolve the issue.
When you use div tags be careful with padding and margins, because they vary depending on the browser you choose
I viewed this code in Chrome ..
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Untitled Page</title>
    <style>
    .wideBox {
  clear: both;
  width: 90%;
  text-align: center;
  margin: 70px;
  padding: 10px;
  background: #FFFFFF;
  border: 1px solid grey;
}
.loginBox {
    width: 20%;
      margin: 70px;
      height: auto;
    float:left; /* add this */
    border: 1px solid grey;
      padding: 10px;
}
.newsBox {
    border: 1px solid grey;
      width: 65%;
    overflow: hidden; /* if you don't want #second to wrap below #first */
      display: block;
      font-size: 1.2em;
      padding: 10px;
}</style>
</head>
<body>
<div class="wideBox"></div>
<div class="loginBox"></div>
<div class="newsBox"></div>
</body>
</html>

Open in new window

You can adjust width and height based on your requirements. I just used your code to make sample.
Out put viewed as attached image
output
0
 
LVL 39

Author Comment

by:blue-genie
Comment Utility
genemi - the changes you suggest don't seem to do it, the newbox (Bottom right) wraps under the login box (bottom left)

anuradhay - i get the following if i copy / paste your code.

not top aligned.
0
 
LVL 3

Accepted Solution

by:
gnemi earned 500 total points
Comment Utility
Tested in Chrome, FF, and IE8

<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Untitled Page</title>
    <style>
.wideBox {
  border: 1px solid grey;
  margin: 2% 5% 2% 5%;
  padding: 10px;
  text-align: center;
}
.loginBox {
  border: 1px solid grey;
  margin-left: 5%;
  padding: 10px;
  float: left;
  width: 20%;
}
.newsBox {
  border: 1px solid grey;
  margin-right: 5%;
  padding: 10px;
  float: right;
  width: 65%;
}</style>
</head>
<body>
<div class="wideBox"></div>
<div class="loginBox"></div>
<div class="newsBox"></div>
</body>
</html>

Open in new window

0
 
LVL 39

Author Closing Comment

by:blue-genie
Comment Utility
thanks alot - i'll be back once i get a little further in my css journey :-)
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

When applying CSS to your HTML, there are many different ways to select which element(s) the CSS applies to.  Some of these selectors are more commonly known and used than others - Here are the more common ones: #X - Matches an ID of X .X - Matche…
This is a how to build your own CSS3 slideshow and when I say CSS3 I mean just CSS with no javascript in sight! There a few examples online of how to do this but most just show you an example without any explanation, others make it more complicat…
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

5 Experts available now in Live!

Get 1:1 Help Now