Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Casey Runnells
Courses Plus Student 5,765 Pointsul a center alignment issue
I'm trying to figure out why my unordered list of anchors is slightly off center within the parent div. Can someone point out what I need to tweak to get the links perfectly centered?
here's the html
<!DOCTYPE HTML>
<html lang="en">
<title>Indigo Beyond</title>
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" >
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<div class="wrapper">
<p>
<h1>(Replace with Logo)</h1>
<h2>(Replace with Message)</h2>
</p>
<div class="table">
<ul>
<li><a class="fa fa-facebook-square"></a></li>
<li><a class="fa fa-twitter-square"></a></li>
<li><a class="fa fa-instagram"></a></li>
<li><a class="fa fa-cloud"></a></li>
</ul>
</div>
</div>
</body>
</html>
and here's my css:
html {
height: 100%;
}
body {
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
background: #70bg32;
background-repeat:no-repeat;
background: -webkit-linear-gradient(top, #6600CC, #66FFFF) no-repeat;
background: -moz-linear-gradient(top, #6600CC, #66FFFF) no-repeat;
background: -o-linear-gradient(top, #6600CC, #66FFFF) no-repeat;
background: -ms-linear-gradient(top, #6600CC, #66FFFF) no-repeat;
background-size: auto;
}
.wrapper {
width: 300px;
height: 200px;
background-color: red;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
}
h1, h2 {
color: #fff;
text-align: center;
vertical-align: center;
}
.table {
display: table;
margin: 0 auto;
}
.table ul li { display: inline; }
.table ul li a {
text-decoration: none;
padding: .2em;
font-size: 1.5em;
color: rgba(250,250,250,.7);
}
1 Answer
Wolfgang Criollo
1,776 Pointsdon't see the html setup ... does the parent div have padding or margin or the ul ? does the element you trying to center ( ul ) have a width if you trying to center with margin:0 auto ?