I am trying to align multiple buttons side by side and keep the responsive design. Can you please tell me what I am doing wrong here?
Here is the jsfiddle link: jsfiddle
.round-button {
width: 25%;
}
.round-button-circle {
width: 100%;
height: 0;
padding-bottom: 100%;
border-radius: 50%;
border: 10px solid #cfdcec;
overflow: hidden;
background: #4679BD;
box-shadow: 0 0 3px gray;
}
.round-button-circle:hover {
background: #30588e;
}
.round-button a {
display: block;
float: left;
width: 100%;
padding-top: 50%;
padding-bottom: 50%;
line-height: 1em;
margin-top: -0.5em;
text-align: center;
color: #e2eaf3;
font-family: Verdana;
font-size: 1.2em;
font-weight: bold;
text-decoration: none;
}
<div class="round-button">
<div class="round-button-circle">
<a href="http://example.com" class="round-button">Button!!</a>
<a href="http://example.com" class="round-button">Button!!</a>
</div>
</div>
If you want two buttons in two different circles, then here is the solution.
You should change your html structure to this:
<div class="round-button">
<div class="round-button-circle">
<a href="http://example.com" class="round-button">Button!!</a>
</div>
</div>
<div class="round-button">
<div class="round-button-circle">
<a href="http://example.com" class="round-button">Button!!</a>
</div>
</div>
and here is the css code:
.round-button {
width: 25%;
display: inline-block;
margin-right: 25px;
}
.round-button-circle {
width: 100%;
height: 0;
padding-bottom: 100%;
border-radius: 50%;
border: 10px solid #cfdcec;
overflow: hidden;
background: #4679BD;
box-shadow: 0 0 3px gray;
}
.round-button-circle:hover {
background: #30588e;
}
.round-button a {
display: block;
float: left;
width: 100%;
padding-top: 50%;
padding-bottom: 50%;
line-height: 1em;
margin-top: -0.5em;
text-align: center;
color: #e2eaf3;
font-family: Verdana;
font-size: 3vw;
font-weight: bold;
text-decoration: none;
}
This is just for your information , if you want the two buttons side by side there is no need too much of div you can simply do with one div and anchor tags, i have modified your code like this way , please Run the below snippet ,
.button_wrap {
text-align:center;
}
.button_wrap a {
width: 150px;
height: 150px;
border-radius: 50%;
border: 10px solid #cfdcec;
overflow: hidden;
background: #4679BD;
box-shadow: 0 0 3px gray;
display:inline-table;
text-align: center;
color: #e2eaf3;
font-family: Verdana;
font-size: 1.2em;
font-weight: bold;
text-decoration: none;
margin:0 5px;
}
.button_wrap a span {
display:table-cell;
vertical-align:middle;
}
.button_wrap a:hover {
background: #30588e;
}
<div class="button_wrap">
<a href="http://example.com"><span>Buttons</span></a>
<a href="http://example.com"><span>Buttons</span></a>
</div><!-- /.button_wrap -->
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With