I am trying to create a footer with unordered list elements. Below these lists I want to have a second div container with the copyright in it.
This is what I want to achieve
And this is my code so far
.list {
list-style: none;
display: inline-block;
}
#imprintContent {
border-bottom: 1px solid #656a70;
}
<div id="imprint">
<div id="imprintContent">
<ul class="list">
<li>Company</li>
<li>Street</li>
<li>Location</li>
<li>
Mail
</li>
</ul>
<ul class="list">
<li>Small text</li>
<li>
Privacy
</li>
</ul>
</div>
<div id="copyright">
© Copyright
</div>
</div>
How can I center these lists, place a small line below them (maybe a bottom border) and place the copyright below this border?
A free space should remain on the left and right. You can see a working example footer here
https://www.hashicorp.com/contact
if your issee is making footer center, just use text-align to center
.list {
list-style: none;
display: inline-block;
}
#imprintContent {
border-bottom: 1px solid #656a70;
}
#imprint {
text-align:center
}
<div id="imprint">
<div id="imprintContent">
<ul class="list">
<li>Company</li>
<li>Street</li>
<li>Location</li>
<li>
Mail
</li>
</ul>
<ul class="list">
<li>Small text</li>
<li>
Privacy
</li>
</ul>
</div>
<div id="copyright">
© Copyright
</div>
</div>
Hi
This problem can be easily solved with flexbox.
#imprint{
margin: 0% 20%; /*this make the free space to the sides, adjust the 20% to the desired number*/
}
#imprintContent{
display: flex;
justify-content: center;
align-items: center;
}
#green{
background: green;
}
#red{
background: red;
}
#copyright{
text-align: center;
}
.list{
padding: 10%;
margin: 10%;
}
.list > li{
margin-top: 4%;
margin-bottom: 4%;
}
<div id="imprint">
<div id="imprintContent">
<ul id="green" class="list">
<li>Company</li>
<li>Street</li>
<li>Location</li>
<li>
Mail
</li>
</ul>
<ul id="red" class="list">
<li>Small text</li>
<li>
Privacy
</li>
</ul>
</div>
<hr>
<div id="copyright">
© Copyright
</div>
</div>
You can do this
#imprint { display:table; margin:0 auto; }
This is a start. . .
body * {...} is just a reset.
body * {
margin: 0;
padding: 0;
}
footer {
max-width: 60%;
margin: 0 auto;
}
li {
list-style-type: none;
}
.lists {
display: flex;
margin-bottom: 2rem;
}
.lists__list {
flex: 1 auto;
}
.footer__copyright {
border-top: 1px solid black;
padding-top: 2rem;
text-align: center;
}
<footer>
<div class="lists">
<ul class="lists__list">
<li>Company</li>
<li>Street</li>
<li>Location</li>
<li>
Mail
</li>
</ul>
<ul class="lists__list">
<li>Small text</li>
<li>
Privacy
</li>
</ul>
</div>
<div class="footer__copyright">
© Copyright
</div>
</footer>
Related
i have a section, and inside of it an ul with 4 li. In each li a div that are going to be cards. I want to centralize the text inside the div and put it closer to the bottom.
I tried using float: left, and then change the position with margin top and left, but i cannot centralize it.
.cards2 {
text-align: center;
}
.list2 {
list-style: none;
}
.list2 li {
display: inline-block;
}
.cardd2 {
width: 200px;
height: 300px;
background-color: blue;
}
.list2 p {
text-align: center;
}
<section class="cards2">
<ul class="list2">
<li>
<div class="cardd2" id="card1">
<p>Sobre mim</p>
</div>
</li>
<li>
<div class="cardd2" id="card2">
<p>Projetos</p>
</div>
</li>
<li>
<div class="cardd2" id="card3">
<p>Habilidades</p>
</div>
</li>
<li>
<div class="cardd2" id="card4">
<p>Contato</p>
</div>
</li>
</ul>
</section>
Add these to .cardd2
display: flex;
align-items: center;
justify-content: space-evenly;
take note of them young padawan, you're gonna use it a lot
also add margin-bottom: 1vh; for separation
.cards2 {
text-align: center;
}
.list2 {
list-style: none;
}
.list2 li {
display: inline-block;
}
.cardd2 {
width: 200px;
height: 300px;
background-color: blue;
display: flex;
align-items: center;
justify-content: space-evenly;
margin-bottom: 1vh;
}
.list2 p {
text-align: center;
}
<section class="cards2">
<ul class="list2">
<li>
<div class="cardd2" id="card1">
<p>Sobre mim</p>
</div>
</li>
<li>
<div class="cardd2" id="card2">
<p>Projetos</p>
</div>
</li>
<li>
<div class="cardd2" id="card3">
<p>Habilidades</p>
</div>
</li>
<li>
<div class="cardd2" id="card4">
<p>Contato</p>
</div>
</li>
</ul>
</section>
I think that this is the code that you want.
I assume that you need to have the text inside lis to be centered vertically and want it to be a bit down to the bottom.
.cards2{
text-align: center;
}
.list2{
list-style: none;
}
.list2 li{
display: inline-block;
}
.cardd2{
width: 200px;
height: 300px;
background-color: rgb(107, 255, 240);
display: flex;
align-content: center;
margin: 10px;
justify-content: center;
}
.list2 p{
text-align: center;
display: flex;
margin-top:100%;
}
<section class="cards2">
<ul class="list2">
<li>
<div class="cardd2" id="card1"><p>Sobre mim</p></div>
</li>
<li>
<div class="cardd2" id="card2"><p>Projetos</p></div>
</li>
<li>
<div class="cardd2" id="card3"><p>Habilidades</p></div>
</li>
<li>
<div class="cardd2" id="card4"><p>Contato</p></div>
</li>
</ul>
</section>
Add the following to .cardd2:
margin-bottom: .25rem;
display: flex;
align-items: center;
justify-content: center;
.cards2 {
text-align: center;
}
.list2 {
list-style: none;
}
.list2 li {
display: inline-block;
}
.cardd2 {
width: 200px;
height: 300px;
background-color: blue;
margin-bottom: .25rem;
display: flex;
align-items: center;
justify-content: center;
}
.list2 p {
text-align: center;
}
<section class="cards2">
<ul class="list2">
<li>
<div class="cardd2" id="card1"><p>Sobre mim</p></div>
</li>
<li>
<div class="cardd2" id="card2"><p>Projetos</p></div>
</li>
<li>
<div class="cardd2" id="card3"><p>Habilidades</p></div>
</li>
<li>
<div class="cardd2" id="card4"><p>Contato</p></div>
</li>
</ul>
</section>
Maybe Like this:-
* {
padding: 0px;
margin: 0px;
}
.list2 {
display: flex;
positition: absloute;
align items: center;
}
<section class="cards2">
<ul class="list2">
<li>
<div class="cardd2" id="card1">
<p>Sobre mim</p>
</div>
</li>
<li>
<div class="cardd2" id="card2">
<p>Projetos</p>
</div>
</li>
<li>
<div class="cardd2" id="card3">
<p>Habilidades</p>
</div>
</li>
<li>
<div class="cardd2" id="card4">
<p>Contato</p>
</div>
</li>
</ul>
</section>
I'm trying to get the icons to look like this, and centered on the page.
HTML:
<aside class="social">
<ul class="smicons">
<li class="fbicon"><img src="img/fbicon.png"></li>
<li class="twicon"><img src="img/twicon.png"></li>
<li class="yticon"><img src="img/yticon.png"></li>
<li class="igicon"><img src="img/igicon.png"></li>
</ul>
</aside>
CSS:
.social {
display: inline-block;
}
.smicons {
background-color: transparent;
list-style-type: none;
border: none;
float: left;
padding-top: 15px;
display: inline-block;
}
here is a solution based on your css .. check the css section and those comments. sorry for my bad english.
.social {
display:block; /*need aside as a block element by default aside is block */
text-align:center;/*text align center set the ul section to center ;*/
}
.smicons {
background-color: transparent;
list-style-type: none;
border: none;
padding-left:0;/*ul element by default padding-left:40px;*/
padding-top: 15px;
display: inline-flex;/*inline-flex set those icon side by side */
}
<aside class="social">
<ul class="smicons">
<li class="fbicon">
<img src="https://cdn2.iconfinder.com/data/icons/social-18/512/Facebook-3-128.png">
</li>
<li class="twicon">
<img src="https://cdn1.iconfinder.com/data/icons/logotypes/32/twitter-128.png">
</li>
<li class="yticon">
<img src="https://cdn2.iconfinder.com/data/icons/social-icons-color/512/youtube-128.png">
</li>
<li class="igicon">
<img src="https://cdn2.iconfinder.com/data/icons/social-icons-33/128/Instagram-128.png">
</li>
</ul>
</aside>
Here is a flexbox solution.
.smicons,
.smicons li {
margin: 0;
padding: 0;
list-style: none;
}
.smicons {
display: flex;
justify-content: center;
}
.smicons li {
margin: 5px;
}
<aside class="social">
<ul class="smicons">
<li class="fbicon"><img src="http://placehold.it/25x25/FC0"></li>
<li class="twicon"><img src="http://placehold.it/25x25/FC0"></li>
<li class="yticon"><img src="http://placehold.it/25x25/FC0"></li>
<li class="igicon"><img src="http://placehold.it/25x25/FC0"></li>
</ul>
</aside>
Managed to get a flexbox layout work in Firefox, Chrome, Edge, Opera.
Would like to make this work in IE11, or know for sure that it is not possible.
I have read about IE11 issues and tried setting height 100% on the container, without success. IE11 content overflows vertically all containers except body.
html,
body {
width: 100%;
height: 100%;
padding: 0;
margin: 0;
}
body {
display: flex;
flex-direction: column;
}
.header,
.footer {
height: 2em;
flex: none;
background-color: orange;
}
.content-wrapper {
flex: 1 0 auto;
width: 100%;
background-color: white;
display: flex;
flex-direction: column;
}
.content {
flex: 1;
width: 100%;
max-width: 60em;
margin: 0 auto;
display: flex;
flex-direction: row;
background-color: red;
}
.main {
flex: 1;
padding: 1em 1em 0;
min-width: 12em;
display: flex;
flex-direction: column;
background-color: blue;
}
.main-body {
flex: 1 0;
background-color: yellow;
}
.main-toc {
order: -1;
background-color: green;
}
.nav {
order: -1;
flex: 0 0 auto;
width: 12em;
}
pre {
position: relative;
padding: 1em;
margin: .5em 0;
overflow: auto;
border-radius: 0.3em;
max-width: 100%;
background-color: silver;
}
<header class="header">
header
</header>
<div class="content-wrapper">
<div class="content">
<main id="main" role="main" class="main">
<div id="main-body" class="main-body">
<h1>H1</h1>
<p>link
</p>
<p>On the other hand, we denounce with righteous indignation ...</p>
<pre><code class="language-php">
public function publicMethodOptionalParam($p1 = null)
{
return true;
}
</code></pre>
<p>On the other hand, we denounce with righteous indignation ...</p>
</div>
<div id="main-toc" class="main-toc">
table of contents
</div>
</main>
<nav id="nav" role="navigation" class="nav">
<ul>
<li class="is-active">Getting Started
<ul>
<li class="is-active">Introduction
</li>
</ul>
</li>
<li class="is-active">Getting Started
<ul>
<li class="is-active">Introduction
</li>
</ul>
</li>
<li class="is-active">Getting Started
<ul>
<li class="is-active">Introduction
</li>
</ul>
</li>
<li class="is-active">Getting Started
<ul>
<li class="is-active">Introduction
</li>
</ul>
</li>
<li class="is-active">Getting Started
<ul>
<li class="is-active">Introduction
</li>
</ul>
</li>
<li class="is-active">Getting Started
<ul>
<li class="is-active">Introduction
</li>
</ul>
</li>
<li class="is-active">Getting Started
<ul>
<li class="is-active">Introduction
</li>
</ul>
</li>
<li class="is-active">Getting Started
<ul>
<li class="is-active">Introduction
</li>
</ul>
</li>
<li class="is-active">Getting Started
<ul>
<li class="is-active">Introduction
</li>
</ul>
</li>
<li class="is-active">Getting Started
<ul>
<li class="is-active">Introduction
</li>
</ul>
</li>
</ul>
</nav>
</div>
</div>
<footer class="footer">
footer
</footer>
Codepen with the above code
Add flex: 1 0 auto; to .content (in css).
See Codepen.
From michaPau's comment. Doing it on his behalf so this question can be resolved since he was unresponsive, and for the solution to be more accessible/explicit to people looking for it.
I am wondering how to center elements within a div but keep the text left aligned.
Here is a jfiddle of what I have so far. I want the text to be in the middle of the div but to maintain its left justification.
http://jsfiddle.net/MgcDU/5994/
HTML:
<div class="span4" id="middleFooter">
<div class="mcont" >
<div class="mrow"> <h5 class="tcell"><b>Useful Links</b></h5> </div>
<ul>
<div class="mrow"> <li class="tcell">Contact Us</li> </div>
<div class="mrow"> <li class="tcell">About Us</li> </div>
<div class="mrow"> <li class="tcell">Copyright Information</li> </div>
<div class="mrow"> <li class="tcell">Terms & Conditions</li> </div>
</ul>
</div>
</div>
CSS:
#middleFooter {
color: #ccc2a0;
}
.mcont {
background-color: blue;
}
.mrow li {
background-color: red;
margin-left: auto;
margin-right: auto;
}
.mrow h5 {
display: table-row;
background-color: yellow;
}
.tcell {
display: table-cell;
}
You can try something like this - http://jsfiddle.net/GxgrL/
html:
<div class="span4" id="middleFooter">
<div class="mcont" >
<div class="mrow"> <h5 class="tcell"><b>Useful Links</b></h5> </div>
<ul>
<li class="tcell">Contact Us</li>
<li class="tcell">About Us</li>
<li class="tcell">Copyright Information</li>
<li class="tcell">Terms & Conditions</li>
</ul>
</div>
</div>
css:
#middleFooter {
color: #ccc2a0;
}
.mcont {
background-color: blue;
}
li {
background-color: red;
display: block;
text-align: center;
}
li a {
background-color: green;
display: inline-block;
margin: 0 auto;
width: 170px;
text-align: left;
}
.mrow {
text-align: center;
}
.mrow h5 {
display: inline-block;
background-color: yellow;
text-align: left;
width: 170px;
}
You can get this effect by making the container div 50% width then floating it to the right. So in your fiddle add:
.mcont {
width: 50%;
float: right;
}
If you want to keep the blue background you'll need to wrap all the .mrow divs in a wrapper and apply the styles above so like:
<div class="mcont" >
<div class="wrapper">
<div class="mrow"> <h5 class="tcell"><b>Useful Links</b></h5> </div>
<ul>
<div class="mrow"> <li class="tcell">Contact Us</li> </div>
<div class="mrow"> <li class="tcell">About Us</li> </div>
<div class="mrow"> <li class="tcell">Copyright Information</li> </div>
<div class="mrow"> <li class="tcell">Terms & Conditions</li> </div>
</ul>
</div>
</div>
Then:
.wrapper {
width: 50%;
float: right;
}
Just assign your .mrow divs a width and give them margin:0px auto and they will be center aligned.
.mrow{
width:20%;
margin:0px auto;
}
Here's an example of your fiddle with that style added: http://jsfiddle.net/HcQcn/
i created a style called "topbar" using css.
The code are as follows:
.topbar:hover ul{ display: inline;}
.topbar {
float: left;
margin-left: 20px;
margin-right: 20px;
font-family:"Georgia";
}
.topbar ul {
display: none;
top:30px;
position: absolute; border-style:solid;
border-width:1px; background-color:white;}
}
.clear {
clear: both;
}
then i went to create a ul "grid" and allows mouse hover enlarge of images
ul.grid, ul.grid > li {
margin: 0;
padding: 0;
}
ul.grid {
}
ul.grid > li {
float: left;
list-style-type: none;
text-align: center;
font-family:"Georgia", serif;
padding-top:50px;
padding-bottom:25px;
padding-right:25px;
padding-left:0px;
}
ul img:hover { width: 200px; height: 250px; }
my html code:
<body>
<div class="topbar">
<p>Title</p>
<ul>
<li>A-Z</li>
<li>Z-A</li>
</ul>
</div>
<div class="topbar">
<p>Genre</p>
<ul>
<li>Action</li>
<li>Comedy</li>
<li>Animation</li>
<li>Horror</li>
<li>Drama</li>
</ul>
</div>
<div class="clear"></div>
<br />
<div id="videos">
<ul class="grid">
<li>
<p class="image"><img src="http://3.bp.blogspot.com/-AGAaic1-yrM/TcWmj77lHzI/AAAAAAAAAkQ/K6zzSk1WgUY/s1600/thor-movie-poster-1.jpg" alt="Thor" width="175" height="200" /></p>
<p class="name">Thor</p>
<p class="genre">Action</p>
<p class="format">DVD</p>
<p class="year">2011</p>
</li>
<li>
<p class="image"><img src="http://www.galacool.com/wp-content/uploads/2010/02/hangover2.jpg" alt="Hangover" width="175" height="200" /></p>
<p class="name">Hangover</p>
<p class="genre">Comedy</p>
<p class="format">DVD</p>
<p class="year">2009</p>
</li>
</ul>
</div>
</body>
Why do i have a left unwanted space beside my "thor" movie image?
The left space must be the indentation of the List where you are putting them. Ideally, to remove this left-indentation, you should set both padding and margins to "0" for the "UL".
This small piece of code works perfectly in this context:
CSS
#navcontainer ul
{
margin: 0;
padding: 0;
list-style-type: none;
}
HTML
<div id="navcontainer">
<ul>
<li>Milk
<ul>
<li>Goat</li>
<li>Cow</li>
</ul>
</li>
<li>Eggs
<ul>
<li>Free-range</li>
<li>Other</li>
</ul>
</li>
</ul>
</div>