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 trialjason limmm
8,009 Pointsunable to center by setting padding to auto
.flex{
display:flex;
}
#selectbuttoncontainer{
align-items:center;
flex-direction: row;
width:100vw;
height:100vh;
}
#selectbuttoncontainer a{
font-size: 8rem;
width:500px;
height:500px;
margin:0 calc(105px/2);
padding:auto;
text-decoration: none;
}
#easy{
border:black solid 10px;
}
#medium{
border:black solid 10px;
}
#hard{
border:black solid 10px;
}
<!DOCTYPE html>
<html>
<head>
<title>Math Exercise Menu</title>
<link rel="stylesheet" href="https://necolas.github.io/normalize.css/8.0.1/normalize.css">
<link rel="stylesheet" href="menustyles.css">
</head>
<body>
<div id="selectbuttoncontainer" class="flex">
<a id="easy" href="easy.html">Easy</a>
<a id="medium" href="medium.html">Medium</a>
<a id="hard" href="hard.html">Hard</a>
</div>
</body>
</html>
i am unable to set the padding of my links so that the text are in the center of the button
1 Answer
Steven Parker
231,198 PointsBoth padding and auto-centering work on block type elements, but anchors (a) are flow elements. So they will only be as wide as they need to be to hold their content. You might center the element itself inside something, but you won't need to center their inside content.
For future postings, consider using a workspace snapshot to make it easy to replicate the issue. See this video about sharing a snapshot of your workspace.
jason limmm
8,009 Pointsjason limmm
8,009 Pointshttps://w.trhou.se/m0ddormqdp here is the snapshot i still can't center the text inside
Steven Parker
231,198 PointsSteven Parker
231,198 PointsI'm still not seeing the issue. At these large font sizes, the words fill up the boxes and don't need centering.
But if I reduce the font size, I can see where you might want to add
text-align: center;
to the anchor properties.jason limmm
8,009 Pointsjason limmm
8,009 Pointsoh ok, but i want the text to be completely centered, horizontally and vertically