Home > Software design >  the full navigation bar is not visible on mobile devices also the text in the middle of the page is
the full navigation bar is not visible on mobile devices also the text in the middle of the page is

Time:11-16

I'm started learing html/css my first project was portfolio and i fell in this issue. the full navigation bar is not visible on mobile devices also the text in the middle of the page is too large.

site source:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>OPGL Portfolio</title>
        <link rel="stylesheet" href="./style.css">
    </head>
    <body>
        <div >
            <div >
                <div >
                    <img src="https://avatars.githubusercontent.com/u/74413191?s=400&u=7076f19ee2d11687d44fe772ee5a76ce3c437679&v=4" alt="logo" height="50px" width="50px">
                    <h1>OPGL</h1>
                </div>
                <div >
                    <a href="./index.html">Home</a>
                    <a href="index.html">About</a>
                    <a href="https://github.com/OPGL">Projects</a>
                    <a href="./utils/mail.html">Contact</a>
                </div>
            </div>
            <div >
                <h1>Hi,<br/>
                    I'm Dawid,<br/>
                    <div>Begginer Developer</div>
                </h1>
                <p>&#60;!-- Begginer Web Developer, see more in about section --&#62;</p>
            </div>
            <div >
                <p>Made by Dawid Ploch via VSCode</p>
            </div>
        </div>
    </body>
</html>
@import url('https://fonts.googleapis.com/css2?family=Abel&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Raleway:ital@1&display=swap');
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
body {
    font-family: 'Montserrat', sans-serif;
    background: #080a0b;
}
.container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 0px 0px 5px 5px;
    width: 100%;
    padding: 20px;
    position: fixed;
    top: 0;
    z-index: 1;
}
.logo {
    color: #fff;
    font-family: 'Abel', sans-serif;
    font-size: 30px;
}
.nav-links {
    display: flex;
    align-items: center;
}
.nav-links a {
    color: #fff;
    text-decoration: none;
    font-family: 'Abel', sans-serif;
    margin-left: 20px;
    font-size: 20px;
    transition: all 0.3s ease;
}
.nav-links a:hover {
    color: #00b894;
}
.content {
    color: rgba(255, 255, 255, 0.75);
    align-items: center;
    justify-content: center;
}
.content h1 {
    font-size: 50px;
    font-family: 'Raleway', sans-serif;
    padding: 20px;
}
.content h1 div {
    font-size: 30px;
}
.content p {
    text-align: center;
    color: gray;
}
.footer {
    display: flex;
    align-items: center;
    overflow: hidden;
    justify-content: center;
    background-color: #0d1012;
    border-radius: 5px 5px 0px 0px;
    min-width: 100%;
    padding: 20px;
    position: absolute;
    bottom: -150px;
    z-index: 1;
}
.footer p {
    color: #fff;
    font-family: 'Abel', sans-serif;
    font-size: 20px;
}

hosted website: link

i expect that Navigation Bar and text should smaller on mobile devices. everything should be 100% visible

CodePudding user response:

You can make the nav links stack by changing display: flex; to display: inline-block; in CSS under .nav-links

And if you want the text in the middle to be smaller you can simply change the font size in this part of your CSS:

.content h1 {
    font-size: 50px;
    font-family: 'Raleway', sans-serif;
    padding: 20px;
}
.content h1 div {
    font-size: 30px;
}

Now to put it all together so this only happens on mobiles and small screens, you can simply just add this code to your CSS under a media query like this:

@media (max-width: 750px) {
  .nav-links {
    display: inline-block;
    align-items: center;
}
  
  .content h1 {
    font-size: 25px;
    font-family: 'Raleway', sans-serif;
    padding: 20px;
}
.content h1 div {
    font-size: 12px;
}
  
}

Here it is working:

@import url('https://fonts.googleapis.com/css2?family=Abel&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Raleway:ital@1&display=swap');
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
body {
    font-family: 'Montserrat', sans-serif;
    background: #080a0b;
}
.container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 0px 0px 5px 5px;
    width: 100%;
    padding: 20px;
    position: fixed;
    top: 0;
    z-index: 1;
}
.logo {
    color: #fff;
    font-family: 'Abel', sans-serif;
    font-size: 30px;
}
.nav-links {
    display: flex;
    align-items: center;
}
.nav-links a {
    color: #fff;
    text-decoration: none;
    font-family: 'Abel', sans-serif;
    margin-left: 20px;
    font-size: 20px;
    transition: all 0.3s ease;
}
.nav-links a:hover {
    color: #00b894;
}
.content {
    color: rgba(255, 255, 255, 0.75);
    align-items: center;
    justify-content: center;
}
.content h1 {
    font-size: 50px;
    font-family: 'Raleway', sans-serif;
    padding: 20px;
}
.content h1 div {
    font-size: 30px;
}
.content p {
    text-align: center;
    color: gray;
}
.footer {
    display: flex;
    align-items: center;
    overflow: hidden;
    justify-content: center;
    background-color: #0d1012;
    border-radius: 5px 5px 0px 0px;
    min-width: 100%;
    padding: 20px;
    position: absolute;
    bottom: -150px;
    z-index: 1;
}
.footer p {
    color: #fff;
    font-family: 'Abel', sans-serif;
    font-size: 20px;
}


@media (max-width: 750px) {
  .nav-links {
    display: inline-block;
    align-items: center;
}
  
  .content h1 {
    font-size: 25px;
    font-family: 'Raleway', sans-serif;
    padding: 20px;
}
.content h1 div {
    font-size: 12px;
}
  
}
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>OPGL Portfolio</title>
        <link rel="stylesheet" href="./style.css">
    </head>
    <body>
        <div >
            <div >
                <div >
                    <img src="https://avatars.githubusercontent.com/u/74413191?s=400&u=7076f19ee2d11687d44fe772ee5a76ce3c437679&v=4" alt="logo" height="50px" width="50px">
                    <h1>OPGL</h1>
                </div>
                <div >
                    <a href="./index.html">Home</a>
                    <a href="index.html">About</a>
                    <a href="https://github.com/OPGL">Projects</a>
                    <a href="./utils/mail.html">Contact</a>
                </div>
            </div>
            <div >
                <h1>Hi,<br/>
                    I'm Dawid,<br/>
                    <div>Begginer Developer</div>
                </h1>
                <p>&#60;!-- Begginer Web Developer, see more in about section --&#62;</p>
            </div>
            <div >
                <p>Made by Dawid Ploch via VSCode</p>
            </div>
        </div>
    </body>
</html>

  • Related