Vertical text / HTML_CSS

Asked

Viewed 73 times

0

I want to know how I can insert a vertical text with CSS, I tried to put

position: absolute;
top: 50%;
left: 25%;
width: 50%;
text-align: center;
vertical-aling:middle;

I think I’m putting the wrong codes or the wrong place, I need to put these three lists below each other, thank you in advance. Beginner Level.

menu {
  width: 800px;
  margin: auto;
}

#menu ul {
  list-style-type: none;
  margin: 0px;
  padding: 0px;
}

#menu ul li {
  float: left;
  padding: 10px 20px;
  background-color: black;
  color: white;
  border-right: 2px solid white;
  cursor: pointer;
  width: 100px;
  text-align: center;
  position: relative;
}

#menu ul li ul {
  position: absolute;
  top: 40px;
  left: 0px;
  display: none;
}

#menu ul li:hover {
  background-color: green;
}

#menu ul li:hover ul {
  display: block;
}
<div id="menu">
  <ul>
    <li>Home</li>
    <li>Localização</li>
    <li>Portifólio
      <ul>
        <li>Portifólio 01</li>
        <li>Portifólio 02</li>
        <li>Portifólio 03</li>
      </ul>
    </li>
  </ul>
</div>

  • Just remove the float: left; who is in #menu ul li {, in the CSS.

  • You want the menu vertical and the subitens opening to the side?

1 answer

0

Changing your code a little, paying attention to the use of tags <a> and <nav>

CSS code:

/* defina uma largura fixa para todo o menu*/
.navigation {
  width: 100px;
}


/* redefinir suas listas e remove os bullets */
.mainmenu, .submenu {
  list-style: none;
  padding: 0;
  margin: 0;
}

/*faça com que todos os links (principal e submenu) tenham preenchimento e cor de fundo */
.mainmenu a {
  display: block;
  background-color: black;
  text-decoration: none;
  padding: 10px 5px;
  color: white;
  border-bottom: 1px solid white;
  cursor: pointer;
  text-align: center;

}

.mainmenu a:hover {
    background-color: green;
}


/* mouse sobre um item .mainmenu,exiba o submenu dentro dele. mudando a altura máxima do submenu de 0 a 200px; */

.mainmenu li:hover .submenu {
  display: block;
  max-height: 200px;
}

.submenu a {
  background-color: black;
}

.submenu a:hover {
  background-color: green;
}

/* Este é o estado inicial de todos os submenus.max-height: 0 então, esconde o conteúdo se transbordar*/
.submenu {
  overflow: hidden;
  max-height: 0;
  -webkit-transition: all 0.5s ease-out;
}

HTML code:

<nav class="navigation">
  <ul class="mainmenu">
    <li><a href="">Home</a></li>
    <li><a href="">Localização</a></li>
    <li><a href="">Portifólio</a>
      <ul class="submenu">
        <li><a href="">Portifólio 01</a></li>
        <li><a href="">Portifólio 02</a></li>
        <li><a href="">Portifólio 03</a></li>
      </ul>
    </li>
  </ul>
</nav>

Working

/* defina uma largura fixa para todo o menu*/
.navigation {
  width: 100px;
}


/* redefinir suas listas e remove os bullets */
.mainmenu, .submenu {
  list-style: none;
  padding: 0;
  margin: 0;
}

/*faça com que todos os links (principal e submenu) tenham preenchimento e cor de fundo */
.mainmenu a {
  display: block;
  background-color: black;
  text-decoration: none;
  padding: 10px 5px;
  color: white;
  border-bottom: 1px solid white;
  cursor: pointer;
  text-align: center;

}

.mainmenu a:hover {
    background-color: green;
}


/* mouse sobre um item .mainmenu,exiba o submenu dentro dele. mudando a altura máxima do submenu de 0 a 200px; */

.mainmenu li:hover .submenu {
  display: block;
  max-height: 200px;
}

.submenu a {
  background-color: black;
}

.submenu a:hover {
  background-color: green;
}

/* Este é o estado inicial de todos os submenus.max-height: 0 então, esconde o conteúdo se transbordar*/
.submenu {
  overflow: hidden;
  max-height: 0;
  -webkit-transition: all 0.5s ease-out;
}
<nav class="navigation">
  <ul class="mainmenu">
    <li><a href="">Home</a></li>
    <li><a href="">Localização</a></li>
    <li><a href="">Portifólio</a>
      <ul class="submenu">
        <li><a href="">Portifólio 01</a></li>
        <li><a href="">Portifólio 02</a></li>
        <li><a href="">Portifólio 03</a></li>
      </ul>
    </li>
  </ul>
</nav>

  • Much appreciated friend, I will study a little more about the semantics part !!

  • @Joãobrasilio Isso! Study more semantics. Some interesting content you can see here: https://www.devmedia.com.br/html-semantico-conheca-os-elements-semanticos-da-html5/38065

  • @Joãobrasilio If the answer served, be sure to classify it as the correct answer that solved your problem.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.