Display: table and max attributes

Josecanalla

I am using a bootstrap carousel. Inside of this, I put images (with unknown width and heigth). The width of the carousel is also unknown because the page is responsive. The heigth is know, for large screens is 500px and for small screens is 300px.

I want to center the images horizontally and vertically in the carousel, for that, I am using this:

HTML

<div class="item">
    <div class="containerOut"><div class="containerIn"><img src...></div></div>
</div>

CSS

.item
{
heigth: 500px; /*for small screens is 300px*/
position: relative;
}
.containerOut
{
display: table;
heigth: 100%;
margin: 0 auto; /*for horizontal align*/
}
.containerIn
{
display: table-cell;
vertical-align: middle;
}
img
{
max-width: 100%;
display: block;
vertical-align: middle;
}

This works fine when the img dimensions are smaller than the width and heigth. But when the heigth img is more than 500px or when the img width is more than the width of the carousel, the img overflows the carousel. And I want to resize the image to completely enter in the carousel, in large and small screens.

I try to put max-width: 100% in the containers, but not works because the display: table attribute. I need the display: table attribute to vertical align, because I try other options but anything works.

What can I do to specify the max-width and max-heigth of 100% of the carousel images? Thanks!

The Spirit of Gordon Bombay

Does this plunker solve the problem?

Here's the summary of changes:

img 
{
width: 100%;
}

.item 
{
height: 500px;
background: blue; /*added a color only to see the height*/
}

Since vertical-align is already on your .containerIn div, you shouldn't need to also apply it to the images.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Display: table and max attributes

From Dev

Max-Width on DIV with Display: Table

From Dev

not able to display Max salary from table (test)

From Dev

how to display min of a column and use max of the same column to filter other attributes in mysql?

From Dev

Tricky Firefox responsive layout issue with display table and max-width

From Dev

Max width in percentage inside table-cell display container

From Dev

If I have a table showing different values, and a formula to display min/max, is there a way to display the corresponding cell?

From Dev

Display CodeLens above attributes

From Dev

Display CodeLens above attributes

From Dev

Display ForeignKey attributes in template

From Dev

Display Shibboleth Attributes in Pyramid

From Dev

How to change max attributes in Weka?

From Dev

max-Function for attributes of objects

From Dev

Display 2 columns from one table having max count in column 3 and display computed sum of values from another table

From Dev

Table with multiple composite attributes

From Dev

How to replace table attributes?

From Dev

XMLport Table Attributes

From Dev

Display all custom attributes Woocommerce

From Dev

Display more attributes in the decision tree

From Dev

How to display to attributes in a select box?

From Dev

How to display XSL attributes on XML

From Dev

Max/min attributes in bootstrap-ui timepicker

From Dev

Nested attributes not being inserted into table

From Dev

parsing HTML table with missing attributes

From Dev

How to get number of attributes in a table

From Dev

ActiveRecord - Getting all Attributes of a Table

From Dev

Locating table with no id or class attributes

From Dev

Join on table with more joining attributes

From Dev

adding two attributes in a table and then use AS

Related Related

  1. 1

    Display: table and max attributes

  2. 2

    Max-Width on DIV with Display: Table

  3. 3

    not able to display Max salary from table (test)

  4. 4

    how to display min of a column and use max of the same column to filter other attributes in mysql?

  5. 5

    Tricky Firefox responsive layout issue with display table and max-width

  6. 6

    Max width in percentage inside table-cell display container

  7. 7

    If I have a table showing different values, and a formula to display min/max, is there a way to display the corresponding cell?

  8. 8

    Display CodeLens above attributes

  9. 9

    Display CodeLens above attributes

  10. 10

    Display ForeignKey attributes in template

  11. 11

    Display Shibboleth Attributes in Pyramid

  12. 12

    How to change max attributes in Weka?

  13. 13

    max-Function for attributes of objects

  14. 14

    Display 2 columns from one table having max count in column 3 and display computed sum of values from another table

  15. 15

    Table with multiple composite attributes

  16. 16

    How to replace table attributes?

  17. 17

    XMLport Table Attributes

  18. 18

    Display all custom attributes Woocommerce

  19. 19

    Display more attributes in the decision tree

  20. 20

    How to display to attributes in a select box?

  21. 21

    How to display XSL attributes on XML

  22. 22

    Max/min attributes in bootstrap-ui timepicker

  23. 23

    Nested attributes not being inserted into table

  24. 24

    parsing HTML table with missing attributes

  25. 25

    How to get number of attributes in a table

  26. 26

    ActiveRecord - Getting all Attributes of a Table

  27. 27

    Locating table with no id or class attributes

  28. 28

    Join on table with more joining attributes

  29. 29

    adding two attributes in a table and then use AS

HotTag

Archive