so I’d like the below button to have a small annotation (smaller font) below its main text but for the solutions, I’ve tried to resize the entire button and put
.kafelek {
background-color: #C3CECB;
border-radius: 5px;
text-align: center;
width: 230px;
height: 100px;
font-family: 'Open Sans';
font-size: 20px;
color: #003C3D;
margin-top: 15px;
margin-bottom: 1px;
margin-right: 10px;
margin-left: 0px;
display: flex;
align-items: center;
justify-content: center;
}
.kafelek:nth-child(5) {
margin-right: 150px !important;
}
.kafelek:nth-child(6) {
margin-left: 150px !important;
}
.kafelek:hover {
border: 2px solid #7EDF00;
transition: 0.3s;
cursor: pointer;
}
<div class="kafelek">COMING SOON <div class="smallannot"> (Annotation) </div> </div>
the text on the right side instead of just starting a new line.
I’ve tried defining a new class with a smaller font size but it breaks the button entirely (the text doesn’t align properly)
2
Answers
Use this
CSS
, addingflex-direction: column
to the code helps to align the text vertically.After doing so you will get this result,
If you don’t want to use flex simply create a container representing the button and then avoid nesting the divs. They’ll be displayed one under the other.
You can tweak padding/margin to get the design you want. Furthermore, the transition doesn’t go on the hover, it goes on the element being hovered.