Using Text Indent with Text Align - html

I used text-align right in my footer to position my text and unordered list all the way to the bottom right of my page. I would like to have a little bit of space between the text on the bottom right and the edge of my page. After using text align-right, whatever I do, the last part of my text always pushes right up to the edge of my window in the bottom right. I tried playing with the right and left margin but so far this hasn't solved the problem, here is a jsfiddle with my code: http://jsfiddle.net/sdaless/PM5Na/ If anyone can help I'd appreciate it, thanks!
Here is my footer css and html:
html:
<footer>
<div id="footer-container">
<ul id="footerlist">
<hr>
<li>Advertising Programs</li>
<li>Business Solutions</li>
<li>Privacy & Terms</li>
<li>+Google</li>
<li>About Google</li>
</footer>
css:
#footer-container {
padding: 5px 5px;
position: fixed;
bottom: 2px;
width: 100%;
text-align: right;
}
#footer-container ul li a {
color:#656565;
text-decoration: none;
font-size: 13px;
padding: 0 7px;
font-family: Arial;
}
#footerlist li {
display: inline;
list-style-type: none;
}

Change your html to this:
<footer>
<div id="footer-container">
<ul id="footerlist">
<hr>
<li>Advertising Programs</li>
<li>Business Solutions</li>
<li>Privacy & Terms</li>
<li>+Google</li>
<li style='margin-right: 10px'>About Google</li>
</footer>
Or use this css:
#footerlist li:last-child {
margin-right: 10px;
}

use folllowing code:
<footer>
<div id="footer-container">
<ul id="footerlist" style="padding-right:10px">
<hr>
<li>Advertising Programs</li>
<li>Business Solutions</li>
<li>Privacy & Terms</li>
<li>+Google</li>
<li>About Google</li>
</footer>

Either do this:
#footer-container {
padding: 5px 5px;
position: fixed;
bottom: 2px;
left:0; right:0; /* width:100%; */
text-align: right;
}
or this
#footer-container {
padding: 5px 5px;
position: fixed;
bottom: 2px;
width:100%;
box-sizing: border-box; /* so width:100% defines border box */
text-align: right;
}

Related

Can't get a background color to work in CSS

I'm trying to color a footer but it won't appear. I've noticed that if I remove either the "bottom-left" or "bottom-right" class, the list will be colored but it gets out of position. I need to keep it at the bottom and color the whole bottom row. Also, since there are other lists in the webpage, I can't alter the properties of all "li's" like every google search suggested.
HTML:
<footer id="footer">
<ul>
<div>
<span class="bottom-left">
<li>Advertising</li>
<li>Business</li>
<li><a href="pages/how-search-works.html" class="bottom-font"
>How Search works</a></li>
</span>
<span class="bottom-right">
<li>Privacy</li>
<li>Terms</li>
<li>Settings</li>
</span>
</div>
</ul>
</footer>
CSS:
.bottom-font {
font-size: 14px;
color: #5f6368;
line-height: 20px;
word-spacing: 1px;
}
.bottom-right {
position: absolute;
bottom: 0px;
right: 0px;
margin-right: 27px;
}
.bottom-left {
position: absolute;
bottom: 0px;
left: 0px;
margin-left: 27px;
}
#footer{
background: black;
}
You should rather update your HTML to this. You cannot have other elements inside one ul
<footer id="footer">
<div class="bottom-left">
<ul>
<li>Advertising</li>
<li>Business</li>
<li><a href="pages/how-search-works.html" class="bottom-font"
>How Search works</a></li>
</ul>
</div>
<div class="bottom-right">
<ul>
<li>Privacy</li>
<li>Terms</li>
<li>Settings</li>
</ul>
</div>
</footer>
you had no width or height set for your container.
I fixed it.check on codepen: codepen
.bottom-font {
font-size: 14px;
color: #5f6368;
line-height: 20px;
word-spacing: 1px;
}
.bottom-right {
position: absolute;
bottom: 10px;
right: 0px;
margin-right: 27px;
}
.bottom-left {
position: absolute;
bottom: 10px;
left: 0px;
margin-left: 27px;
}
#footer{
position: absolute;/*fixed would work here also*/
bottom: 0;
height: 5rem;
width: 100%;
background: black;
padding-bottom: 10px;
}
ul {
height: inherit;
width: auto;
margin: 0;
}
and in regards to your invalid html structure (ul/li) check this thread
can-i-use-div-as-a-direct-child-of-ul
You need to position your foot on the bottom of the page.
Since you gave it no width and height, it didn't show up.
.bottom-font {
font-size: 14px;
color: #5f6368;
line-height: 20px;
word-spacing: 1px;
}
.bottom-right {
position: absolute;
bottom: 0px;
right: 0px;
margin-right: 27px;
}
.bottom-left {
position: absolute;
bottom: 0px;
left: 0px;
margin-left: 27px;
}
#footer{
background: black;
position: absolute;
height: 80px;
width: 100%;
bottom: 0;
}
<footer id="footer">
<ul>
<div>
<span class="bottom-left">
<li>Advertising</li>
<li>Business</li>
<li><a href="pages/how-search-works.html" class="bottom-font"
>How Search works</a></li>
</span>
<span class="bottom-right">
<li>Privacy</li>
<li>Terms</li>
<li>Settings</li>
</span>
</div>
</ul>
</footer>
I have prepared a leaner solution for you. Please read the comments, the priority here is to understand how flexbox works. Also, I suggest reading on it as much as possible, it is very useful and responsive.
Useful resources that helped me when I started:
https://css-tricks.com/snippets/css/a-guide-to-flexbox/
https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout/Basic_Concepts_of_Flexbox
footer li a { /* this selector targets the links <a> in each <li> and all properties will apply to all of them so you don't separate classes to apply to each li or a */
font-size: 14px;
color: #5f6368;
line-height: 20px;
word-spacing: 1px;
}
footer {
position:absolute;bottom:0; /*this positions the footer at the bottom */
background: black;width:100%; /*here your black background and your width of 100% of the screen width */
display:flex;justify-content:space-between;} /* flex display automatically positions your elements in respect of the rules you add, i.e. here justify-content:space-between so no need for right of left margins of 27px and things like that PLUS it's fully responsive*/
<footer>
<!-- removed "footer" ID you don't need to specify an ID for the footer element you can simply call it footer in your CSS -->
<ul>
<li>Advertising</li>
<li>Business</li>
<li>How Search works</li>
</ul>
<ul>
<li>Privacy</li>
<li>Terms</li>
<li>Settings</li>
</ul>
</footer>
Try to add footer
#footer{
background: black;
position: absolute;
height: 100px;
bottom: 0;
left:0;
right:0;
color:#fff;
}
And make html format correctly,
<footer id="footer">
<div>
<span class="bottom-left">
<ul>
<li>Advertising</li>
<li>Business</li>
<li><a href="pages/how-search-works.html" class="bottom-font"
>How Search works</a></li>
</ul>
</span>
<span class="bottom-right">
<ul>
<li>Privacy</li>
<li>Terms</li>
<li>Settings</li>
</ul>
</span>
</div>
</footer>
Working Demo
.bottom-font {
font-size: 14px;
color: #5f6368;
line-height: 20px;
word-spacing: 1px;
}
.bottom-right {
position: absolute;
bottom: 0px;
right: 0px;
margin-right: 27px;
}
.bottom-left {
position: absolute;
bottom: 0px;
left: 0px;
margin-left: 27px;
}
#footer{
background: black;
position: absolute;
height: 100px;
bottom: 0;
left:0;
right:0;
color:#fff;
}
<footer id="footer">
<div>
<span class="bottom-left">
<ul>
<li>Advertising</li>
<li>Business</li>
<li><a href="pages/how-search-works.html" class="bottom-font"
>How Search works</a></li>
</ul>
</span>
<span class="bottom-right">
<ul>
<li>Privacy</li>
<li>Terms</li>
<li>Settings</li>
</ul>
</span>
</div>
</footer>

How to add space in my navigation bar's right border using html and css only?

I'm having troubles adding a little space in my navigation bar. This is for my activity in school please help
here is a picture navbarpic
my html and css so far is
.nav .container ul li{
display: inline-block;
margin: 10px 18px;
position: relative;
}
.nav li{
border-right: 1px solid black;
}
<body>
<div>
<div class="nav">
<div class="container">
<ul>
<li >HOME</li>
<li>ABOUT US</li>
<li>OUR SERVICES</li></li>
</ul>
</div>
</div>
This is my code so far. I would appreciate any help for this . Thanks in advance :)
You can add few padding on the right side of the li element for the navigation items:
.nav .container ul li{
display: inline-block;
margin: 10px 18px;
position: relative;
}
.nav li{
border-right: 1px solid black;
padding-right: 5%;
}
<div>
<div class="nav">
<div class="container">
<ul>
<li >HOME</li>
<li>ABOUT US</li>
<li>OUR SERVICES</li>
</ul>
</div>
</div>
You can use "pseudo" element to make right border with position: absolute style. it will never break your layout and you can move any white from li.
Hope this will help you :)
.nav .container ul li{
display: inline-block;
margin: 10px 18px;
position: relative;
}
.nav li:after{
content: "";
position: absolute;
height: 100%;
right: -15px;
top: 0;
border-right: 1px solid black;
}
<div>
<div class="nav">
<div class="container">
<ul>
<li >HOME</li>
<li>ABOUT US</li>
<li>OUR SERVICES</li>
</ul>
</div>
</div>

Why is my list appearing under my section instead of in it?

this might be a dumb question but i made a ul for my a footer but it is appearing under the section not in it. I don't know how to move it right next to my picture. Image is attached The footer
#footer {
background: #fdded9;
height: 150px;
width: 960px
}
.footerpic {
display: block;
padding-top: 20px;
padding-left: 30px;
}
ul.copyright {
display: block;
list-style-type: none;
font-family: 'Economica', sans-serif;
font-size 15px;
}
<section id="footer">
<div class="footerpic">
<img src="images/logotransparent.png" alt="pic3" width="100" height="100" />
<ul class="copyright">
<li>About Us</li>
<li>The Team</li>
<li>Contact Us</li>
<li>Privacy Policy</li>
</ul>
</section>
Please help i don't know how to move it and i don't want any white space under my footer if it stuffs up!
You set height: 150px; on the section.
Since the content is taller than 150px, it overflows out of the box.
Leave the height at auto if you want it to expand to contain the content.
Because you made your footer of height:150px.Your content exceeds that value. If you delete it everything must be as you wish.
You are setting the height on the section which is restricting the background height.
You might also want to close the after the list.
#footer {
background: #fdded9;
height: auto; /* 150px */
width: 960px
}
Change display on #copyright from block to inline-block. Then adjust the vertical align of the image. Setting the display to block causes the ul to show up on the next line from the image.
#footer {
background: #fdded9;
height: 150px;
width: 960px
}
.footerpic {
display: block;
padding-top: 20px;
padding-left: 30px;
}
.footerpic img {
vertical-align: bottom;
}
ul.copyright {
display: inline-block;
list-style-type: none;
font-family: 'Economica', sans-serif;
font-size 15px;
}
<section id="footer">
<div class="footerpic">
<img src="images/logotransparent.png" alt="pic3" width="100" height="100" />
<ul class="copyright">
<li>About Us</li>
<li>The Team</li>
<li>Contact Us</li>
<li>Privacy Policy</li>
</ul>
</section>
Just add float:left to CSS
See snippet.
#footer {
background: #fdded9;
height: 150px;
width: 960px
}
.footerpic {
display: block;
float: left;
padding-top: 20px;
padding-left: 30px;
}
ul.copyright {
display: block;
list-style-type: none;
font-family: 'Economica', sans-serif;
font-size 15px;
}
<section id="footer">
<div class="footerpic">
<img src="images/logotransparent.png" alt="pic3" width="100" height="100" />
</div>
<ul class="copyright">
<li>About Us</li>
<li>The Team</li>
<li>Contact Us</li>
<li>Privacy Policy</li>
</ul>
</section>
Use inline block instead of display block to make it in one line like this
#footer {
background: #fdded9;
height:150px;
width:960px
}
.footerpic {
display: inline-block;
padding-top: 20px;
padding-left: 30px;
}
ul.copyright {
display: inline-block;
list-style-type: none;
font-family: 'Economica', sans-serif;
font-size 15px;
}
You can make .footerpic a flex row and it will put the children elements side-by-side, and you can use other flex properties if you want for separation, alignment, etc. Here is a good reference https://css-tricks.com/snippets/css/a-guide-to-flexbox/
#footer {
background: #fdded9;
height: 150px;
width: 960px
}
.footerpic {
display: flex;
padding-top: 20px;
padding-left: 30px;
}
ul.copyright {
display: block;
list-style-type: none;
font-family: 'Economica', sans-serif;
font-size 15px;
}
<section id="footer">
<div class="footerpic">
<img src="images/logotransparent.png" alt="pic3" width="100" height="100" />
<ul class="copyright">
<li>About Us</li>
<li>The Team</li>
<li>Contact Us</li>
<li>Privacy Policy</li>
</ul>
</section>

css navbar with image

I'm trying to make a navbar using CSS. The nav links need to be spaced evenly from the picture in the middle of the bar. At the moment it looks like this:
The Code:
body {
background-image: url("../img/bg.jpg");
margin-left: 0px;
margin-right: 0px;
}
div.menucontainer {
margin-top: 50px;
background-image: url("http://www.thevincentcollection.com/img/menubg.jpg");
height: 35px;
box-shadow: 0px 5px 10px #000;
text-align: center;
}
IMG.vcmenulogo {
position: absolute;
margin-left: auto;
margin-right: auto;
left: 0;
right: 0;
top: 10px;
}
.menulinks {
position: relative;
right: 0px;
list-style:none;
margin:0;
padding:0;
text-align:center;
}
.menulinks li {
display:inline;
}
.menulinks a {
display:inline-block;
padding:10px;
}
#footer {
position: fixed;
background-image: url("http://www.thevincentcollection.com/img/menubg.jpg");
box-shadow: 0px -6px 5px 0px rgba(0,0,0,0.75);
width:100%;
height:20;
bottom:0;
}
P.footer {
text-align: center;
color: white;
font-size: 11px;
font-family: Arial;
}
<!DOCTYPE html>
<html>
<head>
<title>The Vincent Collection: Luxury in Haircare</title>
<link rel="stylesheet" href="css/main.css">
</head>
<body>
<div class="menucontainer">
<img class="vcmenulogo" src="http://www.thevincentcollection.com/img/vc-logo-menu.png" />
<ul class="menulinks">
<li>Home</li>
<li>About</li>
<li>Products</li>
<li>Contact</li>
</ul>
</div>
<div id="footer"> <p class="footer">Copyright © 2016 Salon on Wheels, LLC. All rights reserved.</p> </div>
</body>
</html>
you can change your HTML, insert the img as li and then remove the position:absolute from it and with a few other tweaks regarding position value and vertical-align, you have what you want.
body {
background-image: url("../img/bg.jpg");
margin: 0
}
.menucontainer {
margin-top: 50px;
background-image: url("http://www.thevincentcollection.com/img/menubg.jpg");
height: 35px;
box-shadow: 0px 5px 10px #000;
text-align: center;
}
.menulinks {
position: relative;
top: -90px;
list-style: none;
margin: 0;
padding: 0;
text-align: center;
}
.menulinks li {
display: inline-block;
padding: 10px;
vertical-align: middle
}
<div class="menucontainer">
<ul class="menulinks">
<li>Home
</li>
<li>About
</li>
<li>
<img class="vcmenulogo" src="http://www.thevincentcollection.com/img/vc-logo-menu.png" />
</li>
<li>Products
</li>
<li>Contact
</li>
</ul>
If you are trying to add some space between 2nd and 3rd button as I understood
just give class to 2nd and 3rd li element and give margin. Or maybe you can just add 2 ul elements and margin between
#joshua, its a gud approach to do as #ryuk said as well, and if i was to do this i would just make a dummy li between 2nd and 3rd child then margin it appropriately.
U can either do this,
<ul class="menulinks">
<li>Home</li>
<li>About</li>
<li class="third">Products</li>
<li>Contact</li>
</ul>
.third{ margin-left: 10% }
or make a dummy between 2nd and 3rd li
<ul class="menulinks">
<li>Home</li>
<li>About</li>
<li class="dummy"></li>
<li>Products</li>
<li>Contact</li>
</ul>
.dummy{
padding-left:10%
}

How do I get the navigation bar to span the width of the page?

I have looked a few questions so far that are very similar to this one, but still can't find the answer to my question. (Please note that I am new to HTML and that this is my first post).
I want to have a navigation bar that spans the width of the page no matter the width of the screen that it is being viewed on. I tried making the 's width 100%, but it still did not do anything.
The code for the navigations bar is here:
<!DOCTYPE html>
<html>
<head>
<style>
nav {
width: 100%;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
}
li {
float: left;
}
a {
display: block;
width: 60px;
background-color: #dddddd;
border-color: #ffffff;
text-align: center;
text-decoration: none;
padding: 10px;
margin: 3px;
border-radius: 4px;
}
a:hover {
font-weight: bold;
background-color: #9b9b9b;
}
a:active {
color: #ff0000;
}
</style>
</head>
<body>
<nav>
<ul>
<li>Home</li>
<li>News</li>
<li>Contact</li>
<li>About</li>
</ul>
</nav>
</body>
</html>
Can you please help me to find a way to make the navigation bar span the width of the page?
Thanks!
If you want to expand the li to be the same size and fill the width of the ul, flexbox can do that.
Modern Browsers - Flexbox
nav {
width: 100%;
background: #333;
margin-bottom: 1em;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
display: flex;
}
li {
flex:1 0 auto;
}
a {
display: block;
/*width: 60px;*/
background-color: #dddddd;
border-color: #ffffff;
text-align: center;
text-decoration: none;
padding:10px 0;
margin: 3px;
border-radius: 4px;
}
a:hover {
font-weight: bold;
background-color: #9b9b9b;
}
a:active {
color: #ff0000;
}
<nav>
<ul>
<li>Home
</li>
<li>News
</li>
<li>Contact
</li>
<li>About
</li>
</ul>
</nav>
<nav>
<ul>
<li>Home
</li>
<li>News
</li>
<li>Contact
</li>
<li>About
</li>
<li>Home
</li>
<li>News
</li>
<li>Contact
</li>
<li>About
</li>
</ul>
</nav>
Alternative Solution: Old Browsers - CSS Tables
nav {
width: 100%;
background: #333;
margin-bottom: 1em;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
display: table;
width: 100%;
table-layout: fixed;
}
li {
display: table-cell;
}
a {
display: block;
/*width: 60px;*/
background-color: #dddddd;
border-color: #ffffff;
text-align: center;
text-decoration: none;
padding: 10px;
margin: 3px;
border-radius: 4px;
}
a:hover {
font-weight: bold;
background-color: #9b9b9b;
}
a:active {
color: #ff0000;
}
<nav>
<ul>
<li>Home
</li>
<li>News
</li>
<li>Contact
</li>
<li>About
</li>
</ul>
</nav>
<nav>
<ul>
<li>Home
</li>
<li>News
</li>
<li>Contact
</li>
<li>About
</li>
<li>Home
</li>
<li>News
</li>
<li>Contact
</li>
<li>About
</li>
</ul>
</nav>
You have already given your nav a width of 100%. Now try adding a width to your LI element in your CSS to evenly distribute them across the 100% width of the nav.
li {
float: left;
width:25%;
}
nav is already 100% width,with this css configuration.Give it some background you will be able to see it.
So right how, the navigation bar is spanning the width of the page, however the objects inside aren't large enough to fill the gap. This can be seen if you add a background color to the navigation bar. What you might consider is center-aligning the objects within the nav bar or expanding the width of each object to near 25%
Are you trying to make the nav tag expand from window edge to window edge?
If so you will want to remove the margin on your body:
body {
margin: 0;
}