2

I am trying to align to the center in Oracle Apex cards by using the static content. My issue is that the alignment is not correct and the card sizes are not equal.

My HTML code:

<head>
    <style>
        .card {
            box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
            transition: 0.3s;
            width: 15%;
            float: left;
            margin-left: 10px;
        }

        .card:hover {
            box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.2);
        }

        .container {
            padding: 12px 18px;
        }
    </style>
</head>

<body>
    <div class="card"><img src="ex1" alt="ex1" style="width:100%">
    <div class="container">
        <h4>
            <p style="text-align:center;">
                <font size="2">
                   <a href="ex1 website" target="_blank">
                        <b>ex1</b>
                    </a>
                </font>
            </p>
        </h4>
    </div>
</div>
<div class="card">
    <img src="ex2" alt="ex2" style="width:100%"/>
    <div class="container">
        <h4>
            <p style="text-align:center;">
                <font size="2">
                    <a href="ex2 website" target="_blank">
                        <b>ex2</b>
                    </a>
                </font>
            </p>
        </h4>
    </div>
</div>
</body>

Issue illustration:

result vs expected

behnam shateri
  • 1,223
  • 13
  • 18
souzan 88
  • 21
  • 1
  • 1
  • 4

4 Answers4

1

Create one div outer of the "card" and use below CSS:

.card{
    display: flex;
    align-items: center;
    justify-content: center;
}
jitu thakur
  • 740
  • 3
  • 8
0

add cards inside flex-container

<div class="flex-container">
 <div class="card"></div>
 <div class="card"></div>
</div>

and add this to your CSS

<style>
.flex-container{display: flex;justify-content: space-around;background:#fff;}
</style>
sai m
  • 1
  • 1
0

Cards container should be:

.container {
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  padding: 50px 0;
}

align-items: stretch will make cards to have the same height.

padding will add space to the top and bottom of container. Basically it will dictate the height of each cards.

0

I have done some changes, either you can give properties to body but that will effect on every page so add an outer div.

html{
height: 100%;
}
body{
margin:0;
padding:0;
min-height:100%;
}
.card-outer{
  display:flex;
  justify-content: center;
  min-height: 100vh;
}
.card {
            box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
            transition: 0.3s;
            width: 15%;
            float: left;
            margin-left: 10px;
            align-self: center;
        }

        .card:hover {
            box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.2);
        }

        .container {
            padding: 12px 18px;
        }
<head>
    <style>
        
    </style>
</head>

<body>
<div class="card-outer">
    <div class="card"><img src="ex1" alt="ex1" style="width:100%">
    <div class="container">
        <h4>
            <p style="text-align:center;">
                <font size="2">
                   <a href="ex1 website" target="_blank">
                        <b>ex1</b>
                    </a>
                </font>
            </p>
        </h4>
    </div>
</div>
<div class="card">
    <img src="ex2" alt="ex2" style="width:100%"/>
    <div class="container">
        <h4>
            <p style="text-align:center;">
                <font size="2">
                    <a href="ex2 website" target="_blank">
                        <b>ex2</b>
                    </a>
                </font>
            </p>
        </h4>
    </div>
</div>
</div>
</body>
Amarjit Singh
  • 1,152
  • 7
  • 12