The copyright info comes as next menu item, but I want it to come on the next row inside the footer as a centered text so tell me please how I can achive this. Please help. thanks in advance.
/* ----- FOOTER ----- */
.footer-nav{
display: flex;
flex-direction: row;
justify-content: space-between;
list-style: none;
text-align: center;
text-transform: uppercase;
background-color: #333;
padding: 50px;
font-size: 80%;
}
.footer-nav li{
flex-grow: 100%;
}
<div class="wrapper">
<ul class="footer-nav">
<li>About Us</li>
<li>blah</li>
<li><a href="#"blah</a></li>
<li>blah</li>
<p class = "copyright">aaa</p>
</ul>
</div>
Take out background color from your ulr tag and add it to .wrapper
Also remove the p tag from your ul list and place in outside the list but inside the wrapper
Apply a text-align:center to you p tag
remove padding-top and padding-bottom from your footer for a nice fitting
Snippet below
/* ----- FOOTER ----- */
p{
text-align:center;
}
.footer-nav{
display: flex;
flex-direction: row;
justify-content: space-between;
list-style: none;
text-align: center;
text-transform: uppercase;
padding: 50px;
padding-top:0;
padding-bottom:0;
font-size: 80%;
}
.footer-nav li{
flex-grow: 100%;
}
.wrapper{
background-color: #333;
}
<div class="wrapper">
<ul class="footer-nav">
<li>About Us</li>
<li>blah</li>
<li><a href="#"blah</a></li>
<li>blah</li>
</ul>
<p class = "copyright">aaa</p>
</div>
I, you should try using footer element and put <ul> inside and <p> outside of <ul> with a special class to center the text.
CSS :
.footer-nav{
display: flex;
flex-direction: row;
justify-content: space-between;
list-style: none;
text-align: center;
text-transform: uppercase;
padding: 50px;
font-size: 80%;
}
footer{
background-color: #333;
}
.copyright{
text-align: center;
color: white;
}
.footer-nav li{
flex-grow: 100%;
}
and HTML :
<div class="wrapper">
<footer>
<ul class="footer-nav">
<li>About Us</li>
<li>blah</li>
<li><a href="#"</a>blah</li>
<li>blah</li>
</ul>
<p class="copyright">aaa</p>
</footer>
</div>
https://jsfiddle.net/nesquimo/u1pq6xvq/
A bunch of ways you could do it. If you want the copyright in your list, you need to wrap it in an li as only an li can be a child of a ul. Then just give that li a width: 100% or flex-basis: 100% and set the parent to flex-wrap: wrap
.footer-nav {
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: space-between;
list-style: none;
text-align: center;
text-transform: uppercase;
background-color: #333;
padding: 50px 50px 25px;
font-size: 80%;
}
.footer-nav li {
flex-grow: 100%;
}
.copyright {
flex-basis: 100%;
margin-top: 25px;
}
<div class="wrapper">
<ul class="footer-nav">
<li>About Us</li>
<li>blah</li>
<li>blah</li>
<li>blah</li>
<li class="copyright"><p>aaa</p></li>
</ul>
</div>
Related
I need to have image on left side and navbar on right side... but the navbar must be vertically centered with image.. On jsfiddle I made it up to set navbar vertically to center but I am not able to put it on the right side... I will be glad for any help.
JSFiddle: https://jsfiddle.net/polluxik/0Lqubpe6/20/
ul {
display: flex;
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
align-items: center;
}
ul img {
height: 100px;
}
li a {
display: block;
color: #262353;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
<ul>
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/7/77/Google_Images_2015_logo.svg/640px-Google_Images_2015_logo.svg.png">
<li><a class="active" href="#">test</a></li>
<li>test2</li>
<li>test3</li>
<li>test4</li>
</ul>
*in jsfiddle I used random image from google as a placeholder
One approach is below, with corrected HTML (the only valid child of a <ul> or <ol> is an <li>, so the <img> is now appropriately wrapped):
ul {
display: flex;
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
align-items: center;
/* aligning the content of the <ul> to the end
of the inline axis: */
justify-content: end;
}
ul img {
height: 100px;
}
li a {
display: block;
color: #262353;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
li:first-child {
/* setting the margin of the inline-end of the
first-child <li> element to 'auto', in order
to push the first-child away from the rest of
the content: */
margin-inline-end: auto;
}
<ul>
<!-- wrapped the <img> in another <li> element for validity: -->
<li><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/7/77/Google_Images_2015_logo.svg/640px-Google_Images_2015_logo.svg.png"></li>
<li><a class="active" href="#">test</a></li>
<li>test2</li>
<li>test3</li>
<li>test4</li>
</ul>
JS Fiddle demo.
References:
justify-content.
margin-inline-end.
We can define the image and navbar items in different div and then using flexbox we can align the two div horizontally using justify-content:space-between.
ul {
display: flex;
justify-content: space-between;
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
align-items: center;
}
.nav {
display: flex;
gap: 10px;
}
ul img {
height: 50px;
}
<ul>
<div class='logo'>
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/7/77/Google_Images_2015_logo.svg/640px-Google_Images_2015_logo.svg.png">
</div>
<div class='nav'>
<li><a class="active" href="#">test</a></li>
<li>test2</li>
<li>test3</li>
<li>test4</li>
</div>
</ul>
I am trying to center my horizontal list to the center of my footer. This is what I have so far in my HTML.
.footer-container {
display: flex;
justify-content: center;
flex-direction: row;
}
.social-media li {
display: inline;
list-style: none;
background-color: gray;
margin: 25px;
padding: 10px;
}
<footer>
<div class="footer-container">
<div class="social-media">
<ul>
<li>Facebook</li>
<li>Twitter</li>
<li>LinkedIn</li>
<li>Pinterest</li>
<li>Instagram</li>
</ul>
</div>
</div>
</footer>
I want the list to be in the dead center of all the white space. Any help is much appreciated.
ul by default has some left padding. You can remove it by applying padding-left: 0px:
.footer-container{
display: flex;
justify-content: center;
flex-direction: row;
}
.social-media li{
display: inline;
list-style: none;
background-color: gray;
margin: 25px;
padding: 10px;
}
.social-media ul{
padding-left:0px;
}
<footer>
<div class="footer-container">
<div class="social-media">
<ul>
<li>Facebook</li>
<li>Twitter</li>
<li>LinkedIn</li>
<li>Pinterest</li>
<li>Instagram</li>
</ul>
</div>
</div>
</footer>
for now i have generated the menu in this way:
nav{
width:1024px;
margin: 0 auto;
}
ul{
display: flex;
justify-content: space-between;
}
li {
border-right: 1.1px solid #333333;
margin: 0 auto;
padding: 0 1em;
text-align: center;
flex-grow: 1;
flex-basis: initial;
text-align: center;
}
the html is:
<nav id="menu">
<ul>
<li>Home</li>
<li>Training & Support</li>
<li>Templates & Forms</li>
<li>Policy Documents</li>
<li>Payment Administration</li>
<li>Tax Compliance</li>
<li>News</li>
</ul>
</nav>
The result is:
But i want that the first and last child are aligned at the start and at the end of the ul container like in the image below
How can i do this?
Have you tried removing text-align: centre; ???Or in li try something like padding-right: 0;Tell me how it works out.
I can't align my list into center of my container,
Refer to the screenshot I provided. Can anyone help me to solve this problem ?
I have tried vertical-align = middle, justify content but still not center.
.pink1 {
background-color: pink;
grid-column: 2/4;
height: auto;
font-family: sans-serif;
}
.pink1>h6 {
text-align: center;
}
.pink1>ul {
list-style: none;
align-items: center;
}
.pink1>ul>li {
font-size: 1em;
vertical-align: middle;
}
<div class="pink1 area">
<h6>Navigation</h6>
<ul>
<li>HOME</li>
<li>ABOUT US</li>
<li>GALLERY</li>
<li>EVENTS</li>
<li>CONTACT US</li>
</ul>
</div>
I expect the h6 and list are align center perfectly on the container.
Simple use text-align: center to center align the text horizontally.
For vertical center, you can use display: flex along with flex-direction: column and justify-content: center
See below example
.pink1 {
background-color: pink;
grid-column: 2/4;
height: auto;
font-family: sans-serif;
display: flex;
flex-direction: column; /*For handling elements vertically*/
justify-content: center; /* to Align items vertically center */
min-height: 500px; /* You can remove this. i have added this to show the difference */
}
.pink1>h6 {
text-align: center;
}
.pink1>ul {
list-style: none;
align-items: center;
margin: 0;
padding: 0
}
.pink1>ul>li {
font-size: 1em;
vertical-align: middle;
text-align: center;
padding: 5px 0;
}
<div class="pink1 area">
<h6>Navigation</h6>
<ul>
<li>HOME</li>
<li>ABOUT US</li>
<li>GALLERY</li>
<li>EVENTS</li>
<li>CONTACT US</li>
</ul>
</div>
You need to add only text-align: center, so content centers between the left and right edges.
.pink1 {
background-color: pink;
grid-column: 2/4;
height: auto;
font-family: sans-serif;
}
.pink1>h6 {
text-align: center;
}
.pink1>ul {
list-style: none;
align-items: center;
}
.pink1>ul>li {
font-size: 1em;
text-align: center;
}
<div class="pink1 area">
<h6>Navigation</h6>
<ul>
<li>HOME</li>
<li>ABOUT US</li>
<li>GALLERY</li>
<li>EVENTS</li>
<li>CONTACT US</li>
</ul>
</div>
Hope! this helps
i have this markup which i gave a background color, but the contents just flow out of the background color, even though i gave it height of 100% and a min-height too.
.nav {
padding: 0;
display: flex;
flex-wrap: nowrap;
flex-direction: column;
justify-content: flex-start;
align-items: flex-start;
height: 40px;
list-style: none;
border: 1px solid red;
}
.nav li {
padding-left: 8px;
padding-right: 8px;
}
<div class="navBar">
<ul class="nav dark-grey">
<li>Home</li>
<li>About</li>
<li>Support</li>
<li>Blog</li>
<li>Blog</li>
</ul>
</div>
I am just trying to build without a framework, please can someone point me in the right direction?
Update the height of .nav to auto instead of 40px, and that should allow it to consume required space.
.nav {
padding: 0;
display: flex;
flex-wrap: nowrap;
flex-direction: column;
justify-content: flex-start;
align-items: flex-start;
height: auto;
list-style: none;
border: 1px solid red;
}
.nav li {
padding-left: 8px;
padding-right: 8px;
}
<div class="navBar">
<ul class="nav dark-grey">
<li>Home</li>
<li>About</li>
<li>Support</li>
<li>Blog</li>
<li>Blog</li>
</ul>
</div>
That is because you are forcing the height to use height: 40px you need to use min-height:40px;
see fiddle
https://jsfiddle.net/bf6nLmL6/
.nav {
padding: 0;
display: flex;
flex-wrap: nowrap;
flex-direction: column;
justify-content: flex-start;
align-items: flex-start;
min-height: 40px;
list-style: none;
border: 1px solid red;
}
I have update the CSS, please check:
.nav {
padding: 0;
display: flex;
height: 40px;
list-style: none;
border: 1px solid red;
}
.nav li {
padding: 8px;
float: left;
}
<div class="navBar">
<ul class="nav dark-grey">
<li>Home</li>
<li>About</li>
<li>Support</li>
<li>Blog</li>
<li>Blog</li>
</ul>
</div>
Second option:
.nav {
padding: 0;
display: flex;
flex-wrap: nowrap;
flex-direction: column;
justify-content: flex-start;
align-items: flex-start;
height: auto;
list-style: none;
border: 1px solid red;
}
.nav li {
padding-left: 8px;
padding-right: 8px;
}
<div class="navBar">
<ul class="nav dark-grey">
<li>Home</li>
<li>About</li>
<li>Support</li>
<li>Blog</li>
<li>Blog</li>
</ul>
</div>
Change :
.nav {
height: 40px;
//other codes...
}
To :
.nav {
height: auto;
//other codes...
}
.nav {
padding: 0;
display: flex;
flex-wrap: nowrap;
flex-direction: column;
justify-content: flex-start;
align-items: flex-start;
height: auto;
list-style: none;
border: 1px solid red;
}
.nav li {
padding-left: 8px;
padding-right: 8px;
}
<div class="navBar">
<ul class="nav dark-grey">
<li>Home</li>
<li>About</li>
<li>Support</li>
<li>Blog</li>
<li>Blog</li>
</ul>
</div>