Jump to content

Simple For Anyone Who Knows About CSS


johnsmith153

Recommended Posts

I need my divs laid out like this

(see code below where I have got it very close)

xxxxxxxxxxx

xxxxxxxxxxx

xxxxxxxxxxx

xxxxx xxxxx

xxxxx xxxxx

xx xx xx xx

 

Also, when I add the javascript I have got, I can open and close these divs, so the css needs to allow them to open and close and move together. If all were closed they would sit neatly together. ( I have got all js, just need these to align up to start with)

 

This is the best I could do so far: (put it isnt quite straight)

 



<div style="width:650px;height:30px;background:#CCFFFF;border:#0099FF;thin;border:#333333;">
ff
</div>
<br />
<div style="width:650px;height:30px;background:#CCFFFF;border:thin;border:#333333;">
ff
</div>
<br />
<div style="width:650px;height:30px;background:#CCFFFF;border:thin;border:#333333;">
ff
</div>
<br />
<div style="width:310px;height:30px;background:#CCFFFF;border:thin;border:#333333;">
ff
</div>

<div style="margin-left:340px;height:30px;background:#CCFFFF;width:310px;border:thin;border:#333333;">
ff
</div>

<div style="width:310px;height:30px;background:#CCFFFF;border:thin;border:#333333;">
ff
</div>

<div style="margin-left:340px;height:30px;background:#CCFFFF;width:310px;border:thin;border:#333333;">
ff
</div>

<div style="width:155px;height:30px;background:#CCFFFF;border:thin;border:#333333;">
ff
</div>

<div style="margin-left:165px;height:30px;background:#CCFFFF;width:155px;border:thin;border:#333333;">
ff
</div> 

<div style="margin-left:330px;height:30px;background:#CCFFFF;width:155px;border:thin;border:#333333;">
ff
</div>

<div style="margin-left:495px;height:30px;background:#CCFFFF;width:155px;border:thin;border:#333333;">
ff
</div>



Link to comment
https://forums.phpfreaks.com/topic/126702-simple-for-anyone-who-knows-about-css/
Share on other sites

I got them to line up properly, at least in FF2, IE6 [haven't tested other browsers].  FYI this layout is not perfect, but a good start.

 

yourpage.html

<html>
<head>
  <link rel="stylesheet" type="text/css" href="test.css" />
</head>
<body>
<!-- top 1 x 3 -->
<div class="long">
ff
</div>

<div class="long">
ff
</div>

<div class="long">
ff
</div>


<!-- middle 2 x 2 -->
<div class="medium">
ff
</div>

<div class="medium" id="right">
ff
</div>
<br />
<div class="medium">
ff
</div>

<div class="medium" id="right">
ff
</div>


<!-- bottom 4 x 1 -->
<br />
<div style="width:155px;height:30px;background:#CCFFFF;border:thin;border:#333333;">
ff
</div>

<div style="margin-left:165px;height:30px;background:#CCFFFF;width:155px;border:thin;border:#333333;">
ff
</div> 

<div style="margin-left:330px;height:30px;background:#CCFFFF;width:155px;border:thin;border:#333333;">
ff
</div>

<div style="margin-left:495px;height:30px;background:#CCFFFF;width:155px;border:thin;border:#333333;">
ff
</div>
</body>
</html>

 

test.css

html {height: 100%;}
*,body { margin: 0; padding: 0; text-align: left;}
br { clear: both;}

div.long {
  width:650px;
  height:30px;
  background:#CCFFFF;
  border: 1px solid #333333;
  margin-bottom: 15px;
}

div.medium {
  width:310px;
  height:30px;
  background:#CCFFFF;
  border: 1px solid #333333;
  float: left;
  margin-bottom: 15px;
}

div.medium#right {
  margin-left: 30px;
}

In the 5 minutes I took to write that, I couldn't.  But I assume with them being placed inside another div with position relative on it, I could get it to work.  I have done it before in other contexts, so I know I can do it.  It's time for you to learn.

"In the 5 minutes I took to write that, I couldn't."

I wish you would have said that from the start, I assumed you knew what you were doing.

 

What it needs is this:

<br style="clear: both;" />

 

 

In the words of a CSS beginner it basically stops the line of floats so you can start again. What I had was the bottom row of 4 assuming they were connected to the middle row. All align-top attempts was going from that line.

 

So it basically needs float:left across each row, with the above command to move it to the next row.

 

Thanks for posting in the first place, nobody else was available - some help is better than none.

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.