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?
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.
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.
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).
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With