Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS keep elements maximum top and left

Tags:

html

css

I am trying to make a website with PHP.

<span style="height:60px;"></span>
<span style="height:90px;"></span>
<span style="height:95px;"></span>
<span style="height:45px;"></span>
<span style="height:60px;"></span>
<span style="height:70px;"></span>
<span style="height:55px;"></span>
<span style="height:60px;"></span>
<span style="height:40px;"></span>

The spans above are some posts.
And its CSS is:

span{
    width:150px;
    margin:1px;
    display:inline-block;
    float:left;
    background-color:#000;
}

I got this result: http://jsfiddle.net/5kPFJ/3

But I need a result like this: http://jsfiddle.net/56ybX/
I used <div> with some CSS to keep these spans maximum top.
But I need this result without the <div> tag.
What should I do?

like image 894
Shameel Kadannamanna Avatar asked May 08 '14 07:05

Shameel Kadannamanna


People also ask

How do you keep proportions in CSS?

In the CSS for the <div>, add a percentage value for padding-bottom and set the position to relative, this will maintain the aspect ratio of the container. The value of the padding determines the aspect ratio. ie 56.25% = 16:9.

How do I make elements stack on top of each other CSS?

Using CSS position property: The position: absolute; property is used to position any element at the absolute position and this property can be used to stack elements on top of each other. Using this, any element can be positioned anywhere regardless of the position of other elements.

How do I keep my div from expanding?

You can simply use the CSS display property with the value inline-block to make a <div> not larger than its contents (i.e. only expand to as wide as its contents).

How do I make an element on top in CSS?

If position: absolute; or position: fixed; - the top property sets the top edge of an element to a unit above/below the top edge of its nearest positioned ancestor. If position: relative; - the top property makes the element's top edge to move above/below its normal position.


1 Answers

you should have some kind of wrapper to hold the column when you float some thing it's display become block so the spans are block now you can't do what you want . you should make 3 column float and inside them put your spans and the container can be any html element you can change the behave of that element with css

like image 147
a.hjamshidi Avatar answered Nov 15 '22 06:11

a.hjamshidi