Flexbox Nav Dropdown Not Under Container - html

I am trying to use a flexbox nav menu with dropdowns for some menus. For some reason, on hover, the dropdown lists are showing up to the right of the container I am hovering on. I would like for them to show below, like a normal nav menu.
Here is a codepen:
http://codepen.io/anon/pen/XbmaBY
HTML:
<nav id="nav">
<ul class="nav-flex">
<li class="nav-brand-flex">
<img src="img.png" \>
</li>
<li class="nav-link-flex nav-flex-dropdown">
Dropdown 1
<div>
<ul>
<li>Link 1</li>
<li>Link 2</li>
<li>Link 3</li>
<li>Link 4</li>
<li>Link 5</li>
<li>Link 6</li>
</ul>
</div>
</li>
<li class="nav-link-flex nav-flex-dropdown">
Dropdown 2
<div>
<ul>
<li>Link 1</li>
<li>Link 2</li>
<li>Link 3</li>
<li>Link 4</li>
<li>Link 5</li>
</ul>
</div>
</li>
<li class="nav-link-flex">
Regular 1
</li>
<li class="nav-link-flex">
Regular 2
</li>
<li class="nav-link-flex">
Regular 3
</li>
</ul>
</nav>
Sass:
.nav-flex {
display: flex;
list-style-type: none;
padding: 0;
background-color: #58575f;
li {
justify-content: center;
a {
align-self: center;
color: white;
font-weight: 300;
font-family: 'Open Sans', sans-serif;
letter-spacing: .4px;
}
}
#media (max-width: 760px) {
padding-top: 0;
flex-wrap: nowrap;
-webkit-flex-wrap: nowrap;
flex-direction: column;
-webkit-flex-direction: column;
background-color: #f6f6f6;
}
}
.nav-link-flex {
display: flex;
padding: 0 12.5px;
position: relative;
#media (max-width: 760px) {
width: 90%;
background-color: #494949;
border-radius: 20px;
margin-bottom: 10px;
margin-left: auto;
margin-right: auto;
font-size: 22px;
padding: 10px;
}
&:hover {
background-color: white;
a {
color: black;
text-decoration: none;
&+ div {
display: block;
}
}
}
a {
&+ div {
border-radius: 0 0 2px 2px;
box-shadow: 0 3px 1px rgba(0,0,0,.05);
display: none;
font-size: 1rem;
position: absolute;
width: 195px;
}
}
}
.nav-brand-flex {
margin-right: auto;
display: flex;
padding: 5px 0;
a {
display: flex;
img {
height: 35px;
align-self: center;
}
}
#media (max-width: 760px) {
margin: 0;
background-color: #494949;
width: 100%;
border-radius: 0;
font-size: 36px;
padding: 10px 0;
margin-bottom: 10px;
}
}
Any help would be greatly appreciated, because I cannot figure out why they are going to the right instead of below.

This happens because the default value of flex-direction is flex-direction: row. You want to override this, by adding flex-direction: column; to .nav-link-flex. So, it should be:
.nav-link-flex {
display: flex;
padding: 0 12.5px;
position: relative;
flex-direction: column; // <-- add this line in your scss
...
By way of example I've added this in to a fork of your pen.

Related

How to specify ids for navbar style

I've glommed together a navbar with its own stylesheet, that works approximately like I want it to. If I uncomment the links to stylesheets for bootstrap, however, many of its properties are overridden. Most noticeably is that the menu items are now in separate rows instead of the same.
<!doctype html>
<title>Navbar Test</title>
<h1>Navbar Test</h1>
<link rel="stylesheet" href="navbartest.css">
<nav class="navbar">
<ul class="nav navbar-nav left-links">
<li><a class="links" href="#">Home</a></li>
<li class="dropdown links">
<span>Menu 1</span>
<ul class="dropdown-content">
<li>Thing 1</li>
<li>Thing 2</li>
<li>Thing 3</li>
</ul>
</li>
<li class="dropdown links">
<span>Menu 2</span>
<ul class="dropdown-content">
<li>Thing 1</li>
<li>Thing 2</li>
</ul>
</li>
<li class="dropdown links">
<span>Menu 3</span>
<ul class="dropdown-content">
<li>Thing 1</li>
<li>Thing 2</li>
<li>Thing 3</li>
<li>Thing 4</li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav right-links">
<li class="dropdown links">
<span>Welcome Brian</span>
<ul class="dropdown-content">
<li>User Settings</li>
<li>Log Out</li>
</ul>
</li>
</ul>
</nav>
<!--
<head>
<meta charset="utf-8">
<link
rel="stylesheet"
href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T"
crossorigin="anonymous">
<link
rel="stylesheet"
href="https://use.fontawesome.com/releases/v5.6.3/css/all.css"
integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/"
crossorigin="anonymous">
<link
rel="stylesheet"
href="https://unpkg.com/bootstrap-table#1.16.0/dist/bootstrap-table.min.css">
<link
rel="stylesheet"
type="text/css"
href="http://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.16.0/extensions/filter-control/bootstrap-table-filter-control.css">
</head>
-->
And here is the stylesheet, navbartest.css:
html { font-family: sans-serif; background: #eee; padding: 1rem; }
body { max-width: 960px; margin: 0 auto; background: white; }
h1 { font-family: serif; color: #377ba8; margin: 1rem 0; }
a { color: #377ba8; }
hr { border: none; border-top: 1px solid lightgray; }
body{
margin:0px;
margin-top:60px;
padding: 0px;
}
.selected{
border-bottom: 2px solid purple;
}
.content { padding: 0 1rem 1rem; }
.content > header { border-bottom: 1px solid lightgray; display: flex; align-items: flex-end; }
.content > header h1 { flex: auto; margin: 1rem 0 0.25rem 0; }
.flash { margin: 1em 0; padding: 1em; background: #cae6f6; border: 1px solid #377ba8; }
.post > header { display: flex; align-items: flex-end; font-size: 0.85em; }
.post > header > div:first-of-type { flex: auto; }
.post > header h1 { font-size: 1.5em; margin-bottom: 0; }
.post .about { color: slategray; font-style: italic; }
.post .body { white-space: pre-line; }
.content:last-child { margin-bottom: 0; }
.content form { margin: 1em 0; display: flex; flex-direction: column; }
.content label { font-weight: bold; margin-bottom: 0.5em; }
.content input, .content textarea { margin-bottom: 1em; }
.content textarea { min-height: 12em; resize: vertical; }
input.danger { color: #cc2f2e; }
input[type=submit] { align-self: start; min-width: 10em; }
nav { background: slategray; display: flex; align-items: center; padding: 0 0.5rem; }
nav h1 { flex: auto; margin: 0; }
nav h1 a { text-decoration: none; padding: 0.25rem 0.5rem; }
nav ul { display: flex; list-style: none; margin: 0; padding: 0; }
nav ul li a, nav ul li span, header .action { display: block; padding: 0.5rem; }
.dropdown {
position: relative;
display: inline-block;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
padding: 12px 16px;
z-index: 10;
}
.dropdown:hover .dropdown-content {
display: block;
}
.left-links{
flex:1 1 200px;
}
.links {
display: inline-block;
text-align: center;
padding: 14px;
color: rgb(0, 0, 0);
text-decoration: none;
font-size: 17px;
font-weight: bolder;
}
.links:hover {
border-bottom: 2px solid purple;
}
I'm aware that the solution is to increase CSS specificity. I'm not sure how to do that. If I want to give it the navbar an identifier like "my-navbar" so that the stylesheet doesn't get overridden, where exactly do I need to make those changes?
instead of using <nav class="navbar"> use <nav id="navbar">. An id has a higher specificity weight then a class. Then for every single CSS line that effect the navbar start with nav#navbar as it raises the specificty weight. The specificity level within the same category (!important; > inline-stye > head-style > CSS) is:
tag#id > tag.class > #id > .class > tag
So if every CSS Selector start with nav#navbar it will already outwieght every framework seelctor that only target tags or classes.

How can i change HTML layout in responsive?

I want to implement below structure in desktop and responsive mode. How can i change the layout of html in responsive mode?
<div class="header grid py-3">
<div class="logo_and_title grid">
<div class="logo grid">
<a id="logoid" href="/" class=" me-3"><img src="logo.png" width="100%" class="img-fluid" ></a>
<h1 id="nameid">Title of website</h1>
</div>
</div>
<div class="menu">
<!-- list of menu items-->
</div>
<div>
CSS code for desktop is:
.grid{
display: grid;
}
.logo_and_title.grid{
grid-template-columns: 3fr 7fr;
grid-gap:1rem;
}
.logo.grid{
grid-template-columns: 2fr 7fr;
}
#nameid,#logoid,.menu{
align-self: center;
}
header{
width:100%;
}
try this:
.header {
background: #002147;
color: #fff;
padding: 8px 20px;
font-family: arial;
display: flex;
justify-content: space-between;
align-items: center;
}
.logo {
display: flex;
align-items: center;
}
.logo a {
display: flex;
}
.logo img {
max-width: 60px;
height: 60px;
border: 2px solid #fff;
}
.nameid {
margin: 0 0 0 15px;
font-size: 20px;
}
.menu .nameid {
display: none;
}
ul {
list-style: none;
margin: 0;
padding: 0;
}
li {
display: inline-block;
margin-right: 10px;
}
#media (max-width: 860px) {
.header {
display: flex;
justify-content: flex-start;
}
.menu {
margin-left: 15px;
}
.nameid {
display: none;
}
.menu .nameid {
display: block;
margin: 0 0 5px 0;
}
}
<div class="header">
<div class="logo_and_title">
<div class="logo">
<a id="logoid" href="/">
<img src="https://www.daily-sun.com/assets/news_images/2017/01/12/DAILYSUN_ZYAN.jpg" width="100%" class="img-fluid" >
</a>
<h1 class="nameid">Title of website</h1>
</div>
</div>
<div class="menu">
<h1 class="nameid">Title of website</h1>
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
<li>Item 4</li>
<li>Item 5</li>
<li>Item 6</li>
<li>Item 7</li>
<li>Item 8</li>
</ul>
</div>
<div>
Working with percentage and not px helps alot when building a responsive web page
.class_name{
width: 100%
}
read the following doc in Bootstrap official docs :
https://getbootstrap.com/docs/5.1/layout/grid/
I guess this helps.

Flexbox space-evenly selector for gaps of element?

Hi i have a navbar created by flex box. Items are space-evenly. I need fill gaps around element with same blue color. And also after hover color will change so i need to select both li elements and gaps is there any way how to select them?.
#menu{
display: flex;
margin-top: 0;
padding: 0;
justify-content: space-evenly;
}
#menu li {
height: 100%;
list-style-type: none;
background:rgba(5, 151, 242, 1);
}
#menu li a{
color:white;
text-decoration: none;
text-transform: uppercase;
line-height: 6.5;
width: 100%;
height: 100%;
}
<ul id="menu">
<li>Link 1</li>
<li>Link 2</li>
<li>Longer Link 3</li>
<li>Link 4</li>
</ul>
Your problem is that you are thinking to complex. you don't need the justify-content: space-evenly;, but you need to let the li-elements grow with: flex-grow: 1;
Also you don't need to use rgba, if you don't use transparency you can use rgb
#menu{
display: flex;
margin-top: 0;
padding: 0;
}
#menu li {
height: 100%;
list-style-type: none;
background:rgb(5, 151, 242);
flex-grow: 1;
text-align: center;
}
#menu li:hover {
background:rgba(155, 5, 242);
}
#menu li a{
color:white;
text-decoration: none;
text-transform: uppercase;
line-height: 6.5;
width: 100%;
height: 100%;
display: block;
}
<ul id="menu">
<li>Link 1</li>
<li>Link 2</li>
<li>Longer Link 3</li>
<li>Link 4</li>
</ul>
EDIT:
I made the whole block clickable as requested additionally. This is done by adding display: block; to the a-elements. A link is normally an inline-element, so this switches it to behave like a block element witch listens to the width/height settings already present in the question.
Instead of using justify-content: space-evenly, you can use flex: 1 for each <li>. You can center the text using text-align: center.
Then, you create your hover effect for each item.
#menu{
display: flex;
margin-top: 0;
padding: 0;
}
#menu li {
height: 100%;
list-style-type: none;
background:rgba(5, 151, 242, 1);
flex: 1;
text-align: center;
transition: 0.3s;
}
#menu li a {
border-left: 1px solid red;
border-right: 1px solid red;
color: white;
text-decoration: none;
text-transform: uppercase;
line-height: 6.5;
height: 100%;
display: inline-block;
}
#menu li:hover {
background: rgba(5, 151, 242, 0.8);
}
<ul id="menu">
<li>Link 1</li>
<li>Link 2</li>
<li>Link 3</li>
<li>Link 4</li>
</ul>

How can I align two parts at the left and right in CSS? [duplicate]

This question already has answers here:
In CSS Flexbox, why are there no "justify-items" and "justify-self" properties?
(6 answers)
CSS align few items on both side with flexbox [duplicate]
(1 answer)
Closed 3 years ago.
I'm implementing navigation bar of github and wanna align two parts at the left and right. Therefore, I used float property, but it didn't work for my code. What is wrong with me?
html {
box-sizing: border-box
}
*,
*:before,
*:after {
box-sizing: inherit;
padding: 0;
margin: 0;
list-style-type: none;
}
body {
font: 16px;
line-height: 1.5;
background-color: black;
}
a {
text-decoration: none;
color: inherit;
}
.navigation {
display: flex;
flex-direction: row;
align-items: center;
width: 100%;
background-color: black;
}
.navigation__left {
border: 2px solid red;
float: left;
}
.navigation__right {
border: 2px solid blue;
float: right;
}
.navigation__left,
.navigation__right {
cursor: pointer;
color: white;
padding: 1rem;
}
.navigation__left img {
height: 4vh;
}
.navigation__left__dropdown {
position: absolute;
margin-top: 1rem;
display: none;
color: black;
background-color: white;
padding: 20px;
border-radius: 3%;
}
.navigation__left:hover {
color: gray;
}
.navigation__left:nth-child(even):hover .navigation__left__dropdown {
display: block;
}
.navigation__right:last-child a {
border: 1px solid white;
padding: 0.5vw 1vw 0.5vw 1vw;
border-radius: 3%;
}
input {
height: 3vh;
width: 15vw;
background-color: gray;
border: 0;
border-radius: 3%;
padding: 10px;
}
input::placeholder {
color: rgba(255, 255, 255, 0.5);
font-size: 0.8rem;
}
<header>
<nav>
<ul class="navigation">
<li class="navigation__left">
<a href="https://github.com">
<img src="github.png" alt="logo">
</a>
</li>
<li class="navigation__left">
Why Github?
<ul class="navigation__left__dropdown">
<li>Dropdown 1</li>
<li>Dropdown 2</li>
</ul>
</li>
<li class="navigation__left">
Enterprise
</li>
<li class="navigation__left">
Explore
<ul class="navigation__left__dropdown">
<li>Dropdown 1</li>
<li>Dropdown 2</li>
</ul>
</li>
<li class="navigation__left">
Marketplace
</li>
<li class="navigation__left">
Pricing
<ul class="navigation__left__dropdown">
<li>Dropdown 1</li>
<li>Dropdown 2</li>
</ul>
</li>
<li class="navigation__right">
<input type="text" placeholder="Search GitHub">
</li>
<li class="navigation__right">
Sign In
</li>
<li class="navigation__right">
Sign Up
</li>
</ul>
</nav>
</header>
JSFIDDDLE
Flexbox ignores floats.
Instead, use margin to separate the left navigation items from the right navigation items.
A common pattern is a navigation bar where some key items are aligned to the right, with the main group on the left.
Auto margins will take up all of the space that they can in their axis — it is how centering a block with margin auto left and right works.
Using auto margins for main axis alignment
Consider using the adjacent sibling combinator to target the first navigation__right element that follows a navigation__left element, and setting margin-left:auto.
.navigation__left + .navigation__right {
margin-left: auto;
}
Demonstration:
html {
box-sizing: border-box
}
*,
*:before,
*:after {
box-sizing: inherit;
padding: 0;
margin: 0;
list-style-type: none;
}
body {
font: 16px;
line-height: 1.5;
background-color: black;
}
a {
text-decoration: none;
color: inherit;
}
.navigation {
display: flex;
flex-direction: row;
align-items: center;
width: 100%;
background-color: black;
}
.navigation__left {
border: 2px solid red;
}
.navigation__left,
.navigation__right {
cursor: pointer;
color: white;
padding: 1rem;
}
.navigation__right {
border: 2px solid blue;
}
.navigation__left+.navigation__right {
margin-left: auto;
}
.navigation__left img {
height: 4vh;
}
.navigation__left__dropdown {
position: absolute;
margin-top: 1rem;
display: none;
color: black;
background-color: white;
padding: 20px;
border-radius: 3%;
}
.navigation__left:hover {
color: gray;
}
.navigation__left:nth-child(even):hover .navigation__left__dropdown {
display: block;
}
.navigation__right:last-child a {
border: 1px solid white;
padding: 0.5vw 1vw 0.5vw 1vw;
border-radius: 3%;
}
input {
height: 3vh;
width: 15vw;
background-color: gray;
border: 0;
border-radius: 3%;
padding: 10px;
}
input::placeholder {
color: rgba(255, 255, 255, 0.5);
font-size: 0.8rem;
}
<header>
<nav>
<ul class="navigation">
<li class="navigation__left">
<a href="https://github.com">
<img src="github.png" alt="logo">
</a>
</li>
<li class="navigation__left">
Why Github?
<ul class="navigation__left__dropdown">
<li>Dropdown 1</li>
<li>Dropdown 2</li>
</ul>
</li>
<li class="navigation__left">
Enterprise
</li>
<li class="navigation__left">
Explore
<ul class="navigation__left__dropdown">
<li>Dropdown 1</li>
<li>Dropdown 2</li>
</ul>
</li>
<li class="navigation__left">
Marketplace
</li>
<li class="navigation__left">
Pricing
<ul class="navigation__left__dropdown">
<li>Dropdown 1</li>
<li>Dropdown 2</li>
</ul>
</li>
<li class="navigation__right">
<input type="text" placeholder="Search GitHub">
</li>
<li class="navigation__right">
Sign In
</li>
<li class="navigation__right">
Sign Up
</li>
</ul>
</nav>
</header>
Incidentally, the Github navigation you referenced has a somewhat more complex structure and uses nested flexboxes.
In this case dont use Flex.
html {
box-sizing: border-box
}
*,
*:before,
*:after {
box-sizing: inherit;
padding: 0;
margin: 0;
list-style-type: none;
}
body {
font: 16px;
line-height: 1.5;
background-color: black;
}
a {
text-decoration: none;
color: inherit;
}
.navigation {
width: 100%;
background-color: black;
}
.navigation__left {
border: 2px solid red;
float: left;
}
.navigation__right {
border: 2px solid blue;
float: right;
}
.navigation__left,
.navigation__right {
cursor: pointer;
color: white;
padding: 1rem;
}
.navigation__left img {
height: 4vh;
}
.navigation__left__dropdown {
position: absolute;
margin-top: 1rem;
display: none;
color: black;
background-color: white;
padding: 20px;
border-radius: 3%;
}
.navigation__left:hover {
color: gray;
}
.navigation__left:nth-child(even):hover .navigation__left__dropdown {
display: block;
}
.navigation__right:last-child a {
border: 1px solid white;
padding: 0.5vw 1vw 0.5vw 1vw;
border-radius: 3%;
}
input {
height: 3vh;
width: 15vw;
background-color: gray;
border: 0;
border-radius: 3%;
padding: 10px;
}
input::placeholder {
color: rgba(255, 255, 255, 0.5);
font-size: 0.8rem;
}
<header>
<nav>
<ul class="navigation">
<li class="navigation__left">
<a href="https://github.com">
<img src="github.png" alt="logo">
</a>
</li>
<li class="navigation__left">
Why Github?
<ul class="navigation__left__dropdown">
<li>Dropdown 1</li>
<li>Dropdown 2</li>
</ul>
</li>
<li class="navigation__left">
Enterprise
</li>
<li class="navigation__left">
Explore
<ul class="navigation__left__dropdown">
<li>Dropdown 1</li>
<li>Dropdown 2</li>
</ul>
</li>
<li class="navigation__left">
Marketplace
</li>
<li class="navigation__left">
Pricing
<ul class="navigation__left__dropdown">
<li>Dropdown 1</li>
<li>Dropdown 2</li>
</ul>
</li>
<li class="navigation__right">
<input type="text" placeholder="Search GitHub">
</li>
<li class="navigation__right">
Sign In
</li>
<li class="navigation__right">
Sign Up
</li>
</ul>
</nav>
</header>
You can set display:flex to inline-block
html {
box-sizing: border-box
}
*,
*:before,
*:after {
box-sizing: inherit;
padding: 0;
margin: 0;
list-style-type: none;
}
body {
font: 16px;
line-height: 1.5;
background-color: black;
}
a {
text-decoration: none;
color: inherit;
}
.navigation {
display: inline-block;
flex-direction: row;
align-items: center;
width: 100%;
background-color: black;
}
.navigation__left {
border: 2px solid red;
float: left;
}
.navigation__right {
border: 2px solid blue;
float: right;
}
.navigation__left,
.navigation__right {
cursor: pointer;
color: white;
padding: 1rem;
}
.navigation__left img {
height: 4vh;
}
.navigation__left__dropdown {
position: absolute;
margin-top: 1rem;
display: none;
color: black;
background-color: white;
padding: 20px;
border-radius: 3%;
}
.navigation__left:hover {
color: gray;
}
.navigation__left:nth-child(even):hover .navigation__left__dropdown {
display: block;
}
.navigation__right:last-child a {
border: 1px solid white;
padding: 0.5vw 1vw 0.5vw 1vw;
border-radius: 3%;
}
input {
height: 3vh;
width: 15vw;
background-color: gray;
border: 0;
border-radius: 3%;
padding: 10px;
}
input::placeholder {
color: rgba(255, 255, 255, 0.5);
font-size: 0.8rem;
}
<header>
<nav>
<ul class="navigation">
<li class="navigation__left">
<a href="https://github.com">
<img src="github.png" alt="logo">
</a>
</li>
<li class="navigation__left">
Why Github?
<ul class="navigation__left__dropdown">
<li>Dropdown 1</li>
<li>Dropdown 2</li>
</ul>
</li>
<li class="navigation__left">
Enterprise
</li>
<li class="navigation__left">
Explore
<ul class="navigation__left__dropdown">
<li>Dropdown 1</li>
<li>Dropdown 2</li>
</ul>
</li>
<li class="navigation__left">
Marketplace
</li>
<li class="navigation__left">
Pricing
<ul class="navigation__left__dropdown">
<li>Dropdown 1</li>
<li>Dropdown 2</li>
</ul>
</li>
<li class="navigation__right">
<input type="text" placeholder="Search GitHub">
</li>
<li class="navigation__right">
Sign In
</li>
<li class="navigation__right">
Sign Up
</li>
</ul>
</nav>
</header>
Remove the display:flex property
.navigation {
flex-direction: row;
align-items: center;
width: 100%;
background-color: black;
}

Why are there spaces between <li>'s? [duplicate]

This question already has answers here:
How to remove the space between inline/inline-block elements?
(41 answers)
Closed 7 years ago.
Why is there a space before all these <li>'s Please Help.
HTML
<div class="links">
<ul>
<li>Page 1</li>
<li>Page 2</li>
<li>Page 3</li>
</ul>
</div>
CSS
.links ul{
display: inline;
}
.links{
display: block;
}
.links li{
display: inline;
}
.links a{
display: inline-block;
width: 290px;
text-align: center;
padding-top: 10px;
padding-bottom: 10px;
border: 1px solid #000;
}
JS Fiddle: http://jsfiddle.net/jy4ojyyt/
Inline-block elements render spaces between them. You can either put the li's on the same line or do some of your styling.
http://jsfiddle.net/jy4ojyyt/1/
<div class="links">
<ul>
<li>Page 1</li><li>Page 2</li><li>Page 3</li>
</ul>
</div>
use Comments <!---->
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
.links ul{
display: inline;
}
.links{
display: block;
}
.links li{
display: inline;
}
.links a{
display: inline-block;
width: 290px;
text-align: center;
padding-top: 10px;
padding-bottom: 10px;
border: 1px solid #000;
}
<div class="links">
<ul>
<li>Page 1</li><!--
--><li>Page 2</li><!--
--><li>Page 3</li>
</ul>
</div>
parent- font-size: 0;
child - font-size - XXpx
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.links ul {
display: inline;
}
.links {
display: block;
}
.links li {
display: inline;
font-size: 0;
}
.links a {
display: inline-block;
width: 290px;
text-align: center;
padding-top: 10px;
font-size: 16px;
padding-bottom: 10px;
border: 1px solid #000;
}
<div class="links">
<ul>
<li>Page 1
</li>
<li>Page 2
</li>
<li>Page 3
</li>
</ul>
</div>