css - Border-top Extending too far -
i've got interesting one: testing methods list-item elements of nav bar spread evenly across length of nav. used display:table , display: table cell method spread , seemed work fine.
when went add ::after element add top-bar , have smoother on-hover effect, found bar extended past wanted -- trying have end of words "communication design". thought i'd resize nav container holding list-elements because it's table/table-cell, when nav resizes, list-items shink along , can never shore last element in list.
is there way either affect size of last table cell or show percentage of ::after element?
code:
html:
<h3>test & co.</h3> <p id="title2">communications design</p> <div id="navcontainer"> <ul> <li>home</li> <li>about</li> <li>work</li> <li>contact</li> </ul> </div>
css:
* { padding: 0; margin: 0; } h3 { padding-left: 140px; display: inline-block; padding-top: 10px; padding-bottom: 25px; } #title2 { display: inline-block; float: right; font-size: 16px; margin-right: 252.5px; padding-top: 14px; padding-bottom: 25px; } #navcontainer { //border: 1px solid black; width: 643px; margin-left: 140px; height: 30px; background: white; } #navcontainer ul { list-style:none; display: table; width: 100%; } #navcontainer ul li { display: table-cell; height: 30px; line-height: 30px; font-family:arial; font-size: 12px; text-align: left; //border: 1px solid black; transition: color .2s ease-in-out; position: relative; } #navcontainer ul li::after { content: ""; display: block; float: right; position: absolute; margin: auto; height: 1px; top: 0; width: 100%; background: #ccc; transition: background-color .2s ease; } #navcontainer ul li:hover::after { background: #8c8c8c; } #navcontainer ul li:hover { color: #a6cfeb; }
Comments
Post a Comment