Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display-inline block and image

Tags:

html

css

I am new in designing and so have some problems...

enter image description here

I need 3 block to be inline and centered, so I tried:

#main .block{
    display: inline-block;
    border: 1px solid #ECEDE8;
    margin: 10px 10px;
    overflow: hidden;
    height: 265px;
    width: 265px;
}

But, when i add an image in to the block, all others goes down.

P.S.

As I see, this problem is in safari, in Firefox all ok.

P.S.S

<div id="main">
<div class="block">main
<img src="style/images/try.png">
</div>
<div class="block">main</div>
<div class="block">main</div>
<div class="block">main</div>
<div class="block">main</div>
<div class="block">main</div>
</div>

P.S.S.S

As I could figure it out thought Google, all problem is in display: inline-block, in safari works display: inline-table. What solution could be?

like image 216
NoNameZ Avatar asked Jun 13 '12 23:06

NoNameZ


People also ask

What is display block and display inline?

The display: inline-block Value Compared to display: inline , the major difference is that display: inline-block allows to set a width and height on the element. Also, with display: inline-block , the top and bottom margins/paddings are respected, but with display: inline they are not.

Are images inline or inline-block?

Paragraphs are block-level elements, which means that they block off a whole line for themselves, and images are inline elements, which means they will automatically be placed next to one another on the same line.

Are images inline-block?

<img> is a replaced element; it has a display value of inline by default, but its default dimensions are defined by the embedded image's intrinsic values, like it were inline-block . You can set properties like border / border-radius , padding / margin , width , height , etc. on an image.

What is the opposite of display inline-block?

opposite of display block is. display : none; it used for deleting and recreating them. You can also consider inline-block : inline-block elements inline elements but they have a width and a height.


1 Answers

You need to set the vertical align property. In this case best option would probably be:

vertical-align: top

So your css should be:

#main .block{
    display: inline-block;
    border: 1px solid #ECEDE8;
    margin: 10px 10px;
    overflow: hidden;
    height: 265px;
    width: 265px;
    vertical-align: top;
}
like image 60
thebiffboff Avatar answered Oct 01 '22 21:10

thebiffboff