-1
I’m trying to perfectly fit a paragraph p
in a list item li
to make a header with options menu (same as the site python.org/downloads, that I am recreating to practice), being the text of each of these options centered vertically and horizontally.
The problem is that when I define width: 100%
for the paragraph, it simply ignores this instruction and gets the shortest possible width, i.e., the width of the word. By defining width: 198px
, which is the size of li
in my viewport, it works absolutely perfect. It even regulates its own size by decreasing the width of the browser. Only I want to tailor my page to larger resolutions, so this is not an option. Follow my snippet in HTML:
<div id = interface>
<header id = header_superior>
<nav id = nav_superior>
<ul>
<li id = hs_python><p>Python</p></li>
<li id = hs_psf><p>PSF</p></li>
<li id = hs_docs><p>Docs</p></li>
<li id = hs_pypi><p>PyPI</p></li>
<li id = hs_jobs><p>Jobs</p></li>
<li id = hs_community><p>Community</p></li>
</ul>
</nav>
</header>
</div>
And my excerpt in CSS (the rest I did not put to not be too extensive, but I believe that is right here the problem):
#header_superior ul {
list-style: none;
width: 100%;
height: 100%;
margin: 0 auto;
padding: 0;
font-size: 0;
}
#header_superior li {
display: inline-block;
color: #999;
width: 16.4%;
height: 47px;
border-left: 1px solid #273643;
border-right: 1px solid #1f3b47;
font-size: 12pt;
}
#header_superior p {
width: 198px;
height: 47px;
display: table-cell;
vertical-align: middle;
text-align: center;
margin: 0 auto;
}
Taking a look at this example for a while: https://jsfiddle.net/yLhjok05/ can help you with something. In Inspector some properties are in :Hover, :active or others. Click with the button.
– Cleverson