Hey guys im having an issue here with my footer when resize the screen / on mobile. My footer text is placed to the left and my ul's are maligned. I attached my code bellow, im looking to keep the same layout on desktop but when the screen shrinks have the footer text align center with the layout but keep the same text styling as well so the uls and li's line up with text-align:left;
https://s32.postimg.org/glxnik7gl/footer.png
HTML:
<footer>
<div class="container" id="contact">
<div class="row">
<div class="col-sm-3">
<a class="navbar-brand" href="#"><span class="logo-text-footer">Company Logo</span></a>
</div>
<div class="col-sm-3">
<ul>Quick Links</ul>
<li>Home</li>
<li>About</li>
<li>Services</li>
<li>Contact</li>
</div>
<div class="col-sm-3">
<ul>Address</ul>
<li>1234 Example Street </li>
<li>City</li>
<li>State</li>
<li>55555</li>
</div>
<div class="col-sm-3">
<li>Call: 555-555-5555</li>
<li>E-Mail: example#gmail.com</li>
<div class="social-icons">
<li>Facebook</li>
<li>YouTube</li>
<li>Instagram</li>
<li>Twitter</li>
</div>
</div>
</div>
<div class="row">
<div class="privacy">
<p>
<?php echo date("Y"); ?> Company Name | All Rights Reserved</p>
</div>
</div>
</div>
</footer>
CSS:
/* Footer */
footer {
height: auto;
background: #3a526a;
}
footer #contact {
height: auto;
min-height: 13em;
}
footer .contact-text {
position: relative;
top: 20em;
}
span.logo-text-footer {
color: #fff;
font-size: 30px;
vertical-align: top;
position: absolute;
bottom: 15px;
}
footer #contact ul {
font-size: 17px;
color: #fff;
text-transform: uppercase;
font-family: 'Myriad Pro';
padding: 0;
}
footer #contact li {
color: #fff;
list-style: none;
font-family: 'Myriad Pro';
padding-top: 5px;
}
footer .social-icons li {
display: inline-block;
}
footer .privacy {
height: 50px;
background: #455e76;
}
footer .privacy p {
color: #fff;
text-align: center;
display: block;
margin: auto;
line-height: 50px
}
Add text-center class in footer. Change col-sm-3 class to col-md-3 col-sm-12 in each div. As this is for mobile view, add following CSS:
#media (max-width: 768px) {
footer {
text-align: center;
}
.navbar-brand {float:none;}
}
Check jsFiddle here.
Alignment in bootstrap is very easy so just you know about some class name like text-center to make alignment in center position, text-right to make alignment in right position, text-left to make alignment in left position.
In your code you are using ul and li but for making responsive design to avoid ul and li . So you can use always work with only div.
Related
I'm trying to create a navbar with the two regions split with white space between. I've tried using float:right and justify-content: space-between, but I'm not sure why it is not doing anything. I would like for site-header-right to go on the right side and site-header-navbar to the left.
I did think of making margins between the two divs but that just seemed like an ugly fix, which may or may not cause responsiveness problems later. (If I'm wrong though about that, please tell me haha).
.site-header-navbar {
display: inline-block;
margin: auto;
}
nav ul {
display: inline-block;
list-style-type: none;
}
nav ul li {
display: inline-block;
margin-right: 20px;
}
nav ul li .sale {
color: #a62120;
}
.site-header-right {
display: inline-block;
margin: auto;
}
.small-container {
display: inline-block;
}
.search-btn {
display: inline-block;
margin-right: 20px;
text-transform: uppercase;
font-family: Arial, Helvetica, sans-serif;
color: #555;
font-size: 12px;
line-height: 1.1;
letter-spacing: 1px;
font-weight: 500;
}
.site-header-right a {
display: inline-block;
margin-right: 20px;
}
.site-navigation {
display: flex;
}
<html>
<body>
<div class="site-header-masthead">
<div class="container">
<div class="row">
<div class="col-12 navbar">
<div class="menu-hamburger"></div>
<div class="toast-logo">
<img src="images/logo.jpeg" width="110px">
</div>
<div class="site-navigation">
<nav class="site-header-navbar">
<ul class="site-nav">
<li>Women</li>
<li>Men</li>
<li>House&Home</li>
<li>Sale</li>
<li>Events</li>
<li>Magazine</li>
<li>Our Approach</li>
</ul>
</nav>
<div class="site-header-right">
<div class="small-container">
<button class="search-btn">Search</button>
<a href="#" class="site-header-wishlist">
<span>Saved</span>
<span>(0)</span>
</a>
Account
<a href="#" class="site-header-cart">
<span>Bag</span>
<span>(0)</span>
</a>
</div>
</div>
</body>
</html>
Add justify-content: space-between; to your flex container (.site-navigation) to move the two child elements to the far left and right. And erase margin: auto; for the two flex items! All other offsets are due to margins (also default margins top and bottom), so you might want to reset these to 0.
.site-header-navbar {
display: inline-block;
}
nav ul {
display: inline-block;
list-style-type: none;
}
nav ul li {
display: inline-block;
margin-right: 20px;
}
nav ul li .sale {
color: #a62120;
}
.site-header-right {
display: inline-block;
}
.small-container {
display: inline-block;
}
.search-btn {
display: inline-block;
margin-right: 20px;
text-transform: uppercase;
font-family: Arial, Helvetica, sans-serif;
color: #555;
font-size: 12px;
line-height: 1.1;
letter-spacing: 1px;
font-weight: 500;
}
.site-header-right a {
display: inline-block;
margin-right: 20px;
}
.site-navigation {
display: flex;
justify-content: space-between;
}
<div class="site-header-masthead">
<div class="container">
<div class="row">
<div class="col-12 navbar">
<div class="menu-hamburger"></div>
<div class="toast-logo">
<img src="images/logo.jpeg" width="110px">
</div>
<div class="site-navigation">
<nav class="site-header-navbar">
<ul class="site-nav">
<li>Women</li>
<li>Men</li>
<li>House&Home</li>
<li>Sale</li>
<li>Events</li>
<li>Magazine</li>
<li>Our Approach</li>
</ul>
</nav>
<div class="site-header-right">
<div class="small-container">
<button class="search-btn">Search</button>
<a href="#" class="site-header-wishlist">
<span>Saved</span>
<span>(0)</span>
</a>
Account
<a href="#" class="site-header-cart">
<span>Bag</span>
<span>(0)</span>
</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
You can use   between your navbars
 
Taking this example as starting point, I am trying to create a navigation bar with a left-aligned and a right-aligned section, ensuring vertical alignment into middle for all the elements inside it.
Unfortunately, the right part is not vertically centered, even if right-aligned and left-aligned classes have both the vertical-align: middle property set. What do I am missing? Here is the code bunch:
header img {
display: inline-block;
}
header nav {
display: inline-block;
font-size: 1em;
vertical-align: middle;
}
header nav ul {
padding: 0;
margin: 0;
}
header nav ul img {
vertical-align: middle;
}
header nav li {
display: inline-block;
}
header nav li a {
display: inline-block;
padding: .4em .8em;
font-size: 1em;
text-decoration: none;
color: black;
background: #eee;
line-height: 1;
}
header .container {
max-width: 800px;
margin: auto;
overflow: hidden;
}
.left-aligned {
float: left;
}
.right-aligned {
float: right;
}
<html>
<body>
<header role="banner">
<div class="container">
<div class="left-aligned">
<img class="left" src="http://placehold.it/200x200">
</div>
<div class="right-aligned">
<nav id="navigation" role="navigation">
<ul>
<li>
<img src="http://placehold.it/100x100">
About Us
</li>
<li>Biographies</li>
<li>Services</li>
<li>Careers</li>
<li>Contact</li>
</ul>
</nav>
</div>
</div>
</header>
</body>
</html>
This is a great use case for flexbox - by adding the following three lines to your container class, you can achieve a left and right aligned section:
display: flex;
justify-content: space-between;
align-items: center;
So your final code will look like this (I've separated HTML and CSS for legibility):
header img {
display: inline-block;
}
header nav {
display: inline-block;
font-size: 1em;
}
header nav ul {
padding: 0;
margin: 0;
}
header nav ul img {
vertical-align: middle;
}
header nav li {
display: inline-block;
}
header nav li a {
display: inline-block;
padding: .4em .8em;
font-size: 1em;
text-decoration: none;
color: black;
background: #eee;
line-height: 1;
}
header .container {
max-width: 800px;
margin: auto;
overflow: hidden;
display: flex;
justify-content: space-between;
align-items: center;
}
<header role="banner">
<div class="container">
<div class="left-aligned">
<img class="left" src="http://placehold.it/200x200">
</div>
<div class="right-aligned">
<nav id="navigation" role="navigation">
<ul>
<li>
<img src="http://placehold.it/100x100">
About Us
</li>
<li>Biographies</li>
<li>Services</li>
<li>Careers</li>
<li>Contact</li>
</ul>
</nav>
</div>
</div>
</header>
This justifies the direct children of the flexbox to horizontally align left and right with space in between. If more than two elements were to exist, they would be placed with equal spacing across the width of the container.
Align items will determine the vertical alignment of elements inside the flexbox.
This is true when flex-direction is not set (default value - row). When flex-direction is set to column, the "axis" affected by justify and align are reversed.
I've looked at it all over the place but I can't seem to figure out the error in my code...it's like as if there's a text-align: right by default on my ul.
my code snippet:
footer {
background-color: #444444;
padding-top: 50px;
padding-bottom: 20px;
}
.info {
margin: 0 auto;
width: 50%;
padding-bottom: 30px;
}
.info div {
display: inline-block;
width: 33%;
vertical-align: top;
color: white;
}
footer div ul {
padding-top: 20px;
}
footer div ul li {
line-height: 1.7em;
font-family: 'Montserrat';
list-style-type: none;
}
footer div h3 {
text-transform: uppercase;
font-size: 20px;
font-family: 'Montserrat', sans-serif;
opacity: 0.9;
}
footer input {
display: block;
}
.underline {
margin-top: 20px;
margin-bottom: 20px;
height: 1px;
background-color: white;
width: 100%;
/*margin:auto;*/
}
<footer>
<section class="info">
<article>
<div>
<h3>About</h3>
<div class="underline"></div>
<ul>
<li>Contact</li>
<li>Features</li>
</ul>
</div>
<div>
<h3>Explore</h3>
<div class="underline"></div>
<ul>
<li>Designers</li>
<li>Journal</li>
</ul>
</div>
<div>
<h3>Connect</h3>
<div class="underline"></div>
<input type="text">
</div>
</article>
<article class="end">
</article>
</section>
</footer>
Here is the link to my codepen code:
https://codepen.io/teenicarus/pen/Ngabex
I appreciate all responses!
Just add padding-left: 0; to the ul CSS (the footer div ul rule) to remove the default left padding.
https://codepen.io/anon/pen/bRoBPp
I'm trying to vertically align the navbar with my website logo and header, but whenever I try to use display: inline-block; and vertical-align: middle; on the , , and tags (which are all in the same div on the top of my website), the navbar goes from horizontal to vertical which is not what I want. I'm also using Bootstrap 4.
Here's my html:
<div id="home">
<div class="page-header">
<div class="container">
<div class="row">
<div class="col-md-4">
<img src="images/test-logo.png">
<h1>Rigid Signs</h1>
</div>
<div class="col-md-8">
<ul class="nav">
<li>Home</li>
<li>Services</li>
<li>Portfolio</li>
<li>About</li>
<li>Contact</li>
</ul>
</div>
</div>
</div>
</div>
</div>
and here's my CSS:
#home {
background: url('../images/workshop-testphoto.jpg') no-repeat center / cover;
height: 844px;
}
.page-header {
background: rgba(0,0,0,.6);
postion: fixed;/*not working*/
padding: 11px 0;
}
.page-header img, .page-header h1 {
display: inline-block;
vertical-align: middle;
}
.page-header img {
width: 88px;
}
.page-header h1 {
font-size: 32px;
color: white;
margin-left: 11px;
}
.page-header .nav {
float: right;
}
.page-header .nav li a {
display: inline-block;
font-size: 22px;
text-decoration: none;
color: #fff;
}
I'm not very good with bootstrap 4, but if anyone knows how I could use bootstrap 4 to also achieve my goal of vertically aligning all elements in my navbar, that would be great aswell
If I'm not wrong, bootstrap grid have "float" styling in it. so col-md-4 and col-md-8 will have float left. so, use inline-block instead of float, and give vertical-align middle for both div. using the current html you're showing, it will be
.row {
font-size: 0; /*to remove blank space between two inline-block element*/
}
.col-md-4, .col-md-8 {
float: none;
display: inline-block;
vertical-align: middle
}
Very new to front-end. I'm designing my site with the Skeleton Responsive Framework and I'm having trouble getting my footer nav to center in the mobile layout. It currently aligns to the left.
I assume I'm targetting something incorrectly. Can anyone help?
Here is the code I am using:
<div class="band bottom">
<footer class="container last">
<hr>
<div class="sixteen footer-nav">
<ul>
<li>Home</li>
<li>Contact</li>
<li>Twitter</li>
<li>Instagram</li>
</ul>
</div>
<div class="eight columns credit">
<p>© 2013 Jacob Taylor</p>
</div>
</footer> <! --- End Container --->
</div> <! --- End Band --->
And here is the CSS for both the desktop and mobile versions respecitvely:
/* Footer */
.bottom footer {
font-size: 12px;
}
div.footer-nav ul,
div.footer-nav ul li {
margin: 0px;
}
div.footer-nav ul li {
display:inline;
float: left;
position: relative;
}
div.footer-nav ul li a {
display:inline-block;
padding: 0px 21px 21px 0px;
color: #2f3239;
text-decoration: none;
}
div.footer-nav ul li a:hover {
color: #2f3239;
text-decoration: underline;
cursor: pointer;
}
div.credit {
text-align: right;
}
/* Footer */
footer.last,
div.credit,
div.footer-nav {
text-align: center;
}
div.footer-nav ul {
text-align:center;
}
Remove the .sixteen class from .footer-nav and set it to something less than 100% i.e. ten perhaps and add margin: 0 auto to .footer-nav
Looking at your code it looks like you are trying to use a 16 column object for the list. Reduce the number of columns to something less than twelve columns. And make sure you are using the class "columns" to get the grid working.
<div class="band bottom">
<footer class="container last footer">
<hr>
<div class="twelve columns footer__links">
<ul class="nav--footer">
<li>Home</li>
<li>Contact</li>
<li>Twitter</li>
<li>Instagram</li>
</ul>
</div>
<div class="four columns">
<div class="credit">© 2013 Jacob Taylor</div>
</div>
</footer>
</div>
On another note, Your css seems very verbose and obfuscated. Take a look at a refactored version of your css and markup. Ideally we want to avoid any extra descendant selectors and calling out unqualified element e.g "div.class_name" when writing a rule.
.footer {
font-size: 12px;
}
.footer__links {
text-align: center;
}
.nav--footer{
margin: 0;
padding: 0;
display: inline;
}
.nav--footer li {
display:inline;
margin-right: 4em;
}
.nav--footer a {
text-decoration: none;
color: #2f3239;
}
.nav--footer a:hover {
color: #2f3239;
text-decoration: underline;
cursor: pointer;
}
.credit {
text-align: right;
}