Issue
I would like to know to align the text in a p
element to be vertically centered.
Here is my code:
p.task{font-family: Arial,Helvetica Neue,Helvetica,sans-serif; font-weight: 700; display: table-cell; vertical-align: middle;}
span.label {float: left; width: 60px; color: red}
span.text {float: left; width: calc(100% - 60px);}
<link href="https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/katex.css" rel="stylesheet"/>
<p class="task">
<span class="label">2</span>
<span class="text">Vypočtěte jednu třetinu z \( 3^{3k+3} \) , kde \( k \space \epsilon \space Z \).</span>
</p>
<script src="https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/katex.js"></script>
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/contrib/auto-render.min.js"
onload="renderMathInElement(document.body);"></script>
Solution
add vertical-center
class to the p.
.vertical-center {
display: flex;
align-items: center;
}
or can add the above 2 style-rules within the task class.
.task {
font-family: Arial,Helvetica Neue,Helvetica,sans-serif;
font-weight: 700;
display: flex;
align-items: center;
}
Answered By - Sudipto Roy Answer Checked By - Pedro (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.