Click here to Skip to main content
15,885,309 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi Team

I have 3 div cards they all seem to overlap to each other, how do i keep them aligned to each other? They must be in the same direction e.g 1, 2, 3 sequential to say.

What I have tried:

// Price Drop is a good example its not overlaping, 3 other ones do overlap.

 <!--Loyalty_Cards icon -->
          <a href="category.html">
          
            <div class="card-container">
              <div class="card">
                <div class="card-body">
                  <div class="row flex-wrap">
                    <div class="col-12">
                      <img src="img/eShop-Images/Price_Drop.png" style="width: 56px;">
                      <h3 class="mb-0">Price Drop</h3>
                    </div>
                </div>
              </div>
            </div>
          </div>
        </a>

          <!--Member virtual icon-->

          <a href="category-full.html">
            <div class="card-container">
                <div class="card">
                    <div class="card-body">
                        <div class="row flex-wrap">
                            <div class="col-12">
                              <img src="img/eShop-Images/Referrals.png" style="width: 56px;">
                              <h3 class="mb-0">Referrals</h3>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
          </a>

          <!--Customer service icon-->
<a href="category-full.html">
  <div class="card-container">
    <div class="card">
      <div class="card-body">
        <div class="row flex-wrap">
          <div class="col-12">
            <img src="img/eShop-Images/Delivery_Tracking.png" style="width: 56px;">
            <h3 class="mb-0">Delivery & Tracking</h3>
          </div>
        </div>
      </div>
    </div>
  </div>
</a>

<!--Return image icon-->
<a href="category-full.html">
  <div class="card-container">
    <div class="card">
      <div class="card-body">
        <div class="row flex-wrap">
          <div class="col-12">
            <img src="img/eShop-Images/Returns.png" style="width: 56px;"> 
            <h3 class="mb-0">Returns</h3> 
          </div>
        </div>
      </div>
    </div>
  </div>
</a>


// css file for div cards
CSS
<pre>#hot .card-container {
    display: inline-block;
    float: left;
  }
  
  #hot .card-container:first-child {
    margin-left: 0;
    float: none;
  }
  
  #hot .card-container:last-child {
    margin-right: 0;
  }
Posted
Updated 14-Apr-23 14:07pm
v2

1 solution

You have posted no CSS for us to work with, so let me show you examples of cards and how others have done, with code and live examples, what you are asking: Cards | CodePen[^]
 
Share this answer
 
Comments
Gcobani Mkontwana 14-Apr-23 20:08pm    
@Graeme_Grant, yes i have added css for these div cards. The examples are indeed main examples but not using that form of css, i have share my own css for these div cards on the above code
Graeme_Grant 14-Apr-23 20:16pm    
Remember, we can't see your screen, so we can't see your code.

Floats are so 90s ... You need to use Flex or Grid as used in the examples in the link posted ... there are literally hundreds of examples for you to learn and get fresh ideas from. The other method is if you see a website with something that you like, eg: cards, is to open the Browser Web Tools and inspect their code. That is how most of us learn from others.

The key thing is that the Parent element constrains the child elements, eg: cards, into their layout.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900