Click here to Skip to main content
15,889,842 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I want the "Home" and "History" tab to take up 100% of the parent div but when I enter 100% in the css it clips out. I also want the overflow to be hidden so making it visible isn't a solution.

HTML:
.bottom {
        background-color: red;
        width: 100%;
        max-width: 3000px;
        max-height: 200px;
        margin: auto;
        display: flex;
        justify-content: center;
        align-content: center;
        align-items: center;
        border-style: solid;
    }
    .navBottom{
        overflow: hidden;
        display: flex;
        justify-content: center;
        align-items: center;

    }   
    .navBottom a {
      color: white;
      text-align: center;
      padding: 1vh 50px;
      max-height: 200px;
      text-decoration: none;
      font-size: 1.8vh;
      border-right: 2px solid black;
      text-shadow: #000 0px 0px 1px,   #000 0px 0px 1px,   #000 0px 0px 1px, #000 0px 0px 1px,   #000 0px 0px 1px,   #000 0px 0px 1px, #000 0px 0px 1px, #000 0px 0px 1px;
    }




CSS:
<pre><div class="bottom">
            <div class="navBottom">
            <a href="../index.html">Home</a>
            <a href="history.html">History</a>
          </div>
            </div>




Full code: https://codepen.io/Marshjek/pen/KQZVBQ


What I have tried:

making padding 100%, making width 100%, tried em, rem, vw and vw
Posted
Updated 16-Jul-23 22:18pm

1 solution

Your pen links to a pen which appears to contain the CodePen home page source, which doesn't help.

If you want the two links to stretch to fill the width of the parent, then you need to add flex-grow: 1; to the style for the links, and for the .navBottom container:
CSS
.navBottom{
    flex-grow: 1;
    ...
}   
.navBottom a {
    flex-grow: 1;
    ...
}

Demo[^]
CSS flexible box layout - CSS: Cascading Style Sheets | MDN[^]
A Complete Guide to Flexbox | CSS-Tricks - CSS-Tricks[^]
 
Share this answer
 
Comments
Graeme_Grant 17-Jul-23 4:23am    
You need to drink coffee first... 😛
Year old question... I don't like how they bubble up...

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