0

I'm currently trying to do a navigation bar in HTML/CSS but I have a problem. I would like to show the titles of the tabs at their right but they're bellow the 'nav' div box and I would like them to be above it.

Here are my html/css files :

@import url('https://fonts.googleapis.com/css2?family=Lato:wght@300&display=swap');

* { font-family: 'Lato', sans-serif; }

.nav {
    position: fixed;
    top: 80px;
    left: 20px;
    bottom: 20px;
    width: 75px;
    height: 90%;
    box-sizing: initial;
    border-radius: 10px;
    border-left: 5px solid #2e3137;
    background: #2e3137;
    overflow-x: hidden;
}

.nav ul {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding-left: 5px;
    padding-top: 20px;
}

.nav ul li {
    position: relative;
    list-style: none;
    width: 100%;
    border-top-left-radius: 15px;
    border-bottom-left-radius: 15px;
}

.nav ul li .title {
    position: absolute;
    top: 15px;
    left: 50px;
    width: 60px;
    height: 30px;
    border-radius: 10px;
    background-color: #000;
    color: #fff;
    
}

.nav ul li .title strong {
    position: absolute;
    left: 10px;
    top: 5px;
}

.nav ul li a {
    position: relative;
    display: block;
    display: flex;
    text-decoration: none;
    color: #fff;
}

.nav ul li a .icon {
    display: block;
    min-width: 60px;
    height: 60px;
    line-height: 65px;
    text-align: center;
}

.nav ul li a .icon ionicon { font-size: 1.5em; }
<!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">

    <!-- CSS Files -->
    <link rel="stylesheet" type="text/css" href="s-sidebar.css">

    <!-- Icons <ion-icon> -->
    <script type="module" src="https://unpkg.com/ionicons@4.5.10-0/dist/ionicons/ionicons.esm.js"></script>
    <script nomodule="" src="https://unpkg.com/ionicons@4.5.10-0/dist/ionicons/ionicons.js"></script>

    <title>Saori - StackOverflow</title>
</head>
<body>
    <div class="nav">
        <ul>
            <li class="list">
                <a href="#">
                    <span class="icon">
                        <ion-icon name="person"></ion-icon>
                    </span>
                </a>
                <div class="title">
                    <strong>Profile</strong>
                </div>
            </li>
            <li class="list">
                <a href="#">
                    <span class="icon">
                        <ion-icon name="chatbubbles"></ion-icon>
                    </span>
                </a>
                <div class="title">
                    <strong>Messages</strong>
                </div>
            </li>
            <li class="list">
                <a href="#">
                    <span class="icon">
                        <ion-icon name="settings"></ion-icon>
                    </span>
                </a>
                <div class="title">
                    <strong>Settings</strong>
                </div>
            </li>
            <li class="list">
                <a href="#">
                    <span class="icon">
                        <ion-icon name="help"></ion-icon>
                    </span>
                </a>
                <div class="title">
                    <strong>About</strong>
                </div>
            </li>
            <li class="list">
                <a href="#">
                    <span class="icon">
                        <ion-icon name="log-in"></ion-icon>
                    </span>
                </a>
                <div class="title">
                    <strong>Login</strong>
                </div>
            </li>
        </ul>
    </div>
</body>
</html>

I tried soimon's answer on CSS - Allow an div to stick out of its parent but it didn't work for me.

What I have :

What I would like to have (bad edit) :

j08691
  • 204,283
  • 31
  • 260
  • 272
TheGabDooSan
  • 55
  • 1
  • 2
  • 8

1 Answers1

1

You will see it if you remove overflow-x: hidden; from .nav but I'm not sure what you are trying to achieve here. The "titles" not above or below "nav". It is wrapped within "nav" because it is a fixed element.

Maria Nirmal
  • 373
  • 1
  • 8