Home > front end >  I can't get rid of a white border in html css when resizing the window
I can't get rid of a white border in html css when resizing the window

Time:11-17

I am trying to do a project for school, but I am stuck in a problem I can't solve. When I'm trying to resize the windows (btw I'm using chrome, you can see in the pics) I'm getting a bottom scrollbar, which works but with a little problem... the text inside the background is getting out of it and when I'm scrolling to right I have a white border where the text appears but the background doesn't expand or idk... I have tried with: float: left; overflow-x: hidden; (which works but I can't use the scrollbar anymore and doesn't expand my background and i have seen this "solution" in other forums) I don't know what to do... please help me... the picture with the code the picture with chrome

*{
    margin: 0;
    padding: 0;
    font-family: 'poppins', sans-serif;
    box-sizing: border-box;
}
.backgroundColor{
    background: #1d2026;
    min-height: 100vh;
    width: 100%;
    color: #1d2026;
    position: absolute;
}

h1 p{
    text-align: center;
    padding-top: 150px;
    padding-bottom: auto;
    font-size: 200px;
    color: #29313f;

}

.roundBtn {
    font-size: 108px;
    color: #29313f;
    background: #1d2026;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0%;
    border: none;
    text-decoration: none;
    margin-top: 50px;
    margin-left: 48%;
}
h4 p{
    font-size: 40px;
    color: #ffff    
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="css/style.css">
</head>
<body> 
<div class="backgroundColor">
    <header>
    <nav>
        <img src="images/logoT.png" class="logoTemp">    
    </nav>
    </header>
    <h1><p>welcome</p></h1>
    
    <a class="roundBtn" href="">
        <ion-icon name="chevron-forward-sharp"></ion-icon>
        <!----<h4><p>Take a look</p></h4></!---->
    </a>
</div>
<script type="module" src="https://unpkg.com/[email protected]/dist/ionicons/ionicons.esm.js"></script>
<script nomodule src="https://unpkg.com/[email protected]/dist/ionicons/ionicons.js"></script>
</body>
</html>
<iframe name="sif1" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>

CodePudding user response:

Use overflow: hidden; on your .backgroundColor class. With this structure that you have the best solution would be to adjust the h1 so that it fits a mobile viewport. To accomplish this I used media queries to change the h1 font-size.

*{
    margin: 0;
    padding: 0;
    font-family: 'poppins', sans-serif;
    box-sizing: border-box;
}
.backgroundColor{
    background: #1d2026;
    min-height: 100vh;
    width: 100%;
    color: #1d2026;
    position: absolute;
    overflow: hidden;
}

h1 p{
    text-align: center;
    padding-top: 150px;
    padding-bottom: auto;
    font-size: 200px;
    color: #29313f;

}

.roundBtn {
    font-size: 108px;
    color: #29313f;
    background: #1d2026;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0%;
    border: none;
    text-decoration: none;
    margin-top: 50px;
    margin-left: 48%;
}
h4 p{
    font-size: 40px;
    color: #ffff    
}

@media only screen and (max-width: 800px) {
  h1 p {
    font-size: 7rem;
  }
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="css/style.css">
</head>
<body> 
<div class="backgroundColor">
    <header>
    <nav>
        <img src="images/logoT.png" class="logoTemp">    
    </nav>
    </header>
    <h1><p>welcome</p></h1>
    
    <a class="roundBtn" href="">
        <ion-icon name="chevron-forward-sharp"></ion-icon>
        <!----<h4><p>Take a look</p></h4></!---->
    </a>
</div>
<script type="module" src="https://unpkg.com/[email protected]/dist/ionicons/ionicons.esm.js"></script>
<script nomodule src="https://unpkg.com/[email protected]/dist/ionicons/ionicons.js"></script>
</body>
</html>
<iframe name="sif2" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>

Obviously, feel free to adjust sizes as necessary.

  • Related