I am trying to center text in boxes on my template. The boxes all display just fine but no matter what I set in the css file the text is not quite centered vertically, but fine horizontally. I’ve used padding to make it better but it’s still not quite right since the text is not always the same number of lines in the item.
css ( A mess of stuff now, I’ve tried various different combinations of the align settings):
th, td {
text-align: center;
vertical-align: middle;
}
table{
width: 100vw;
margin:auto;
}
.item_LoO_Name {
width: 8vw;
height: 10vh;
align-content: center;
background-color: black;
border: 2px solid black;
display: inline-block;
color: white;
border-radius: 15px;
box-sizing: border-box;
vertical-align: middle;
margin-bottom: 4px;
font-size: 2vh;
font-weight: bold;
padding: 2.5vh 0;
}
.item_Outcome_Name {
width: 8vw;
height: 10vh;
align-content: center;
background-color: white;
border: 2px solid black;
display: inline-block;
color: black;
border-radius: 15px;
box-sizing: border-box;
vertical-align: middle;
font-size: 1.5vh;
font-weight: bold;
padding: .5vh
}
.Objective {
width: 8vw;
height: 8vh;
margin: auto;
align-content: center;
background-color: white;
color: black;
border: 2px solid black;
display: inline-block;
vertical-align: middle;
text-align: center;
font-size: 1.5vh;
border-radius: 15px;
box-sizing: border-box;
justify-content: center;
}
Template:
{% extends "Dashboard/layoutreview.html" %}
{% block content %}
<!--
{% if data_entry_button != 1 %}
<div class='themetext'>Themes</div>
{% endif %}
-->
<table>
<!--Create LOO shape and iterate through rows>-->
{% for objtext in rows %}
<tr><td>
<!--Create row of topic shapes and spacer between shapes and apply status color-->
{% for a_text in objtext %}
{% if a_text.objective_position == 1 %}
<div class="item_LoO_Name">
{{ a_text.objective_text|linebreaks}}</div>
{% else %}
{% if a_text.objective_position != 10 %}
<div class="space"></div>
<a href="{% url 'drilldown' a_text.id %}" >
<div class="Objective" style= 'background-color:{{ a_text.objective_background }}' title='{{ a_text.objective_color }}' aria-label='Status is {{ a_text.objective_color }}'>
{{ a_text.objective_text|linebreaks}}</div>
<!-- Adds color as text in Objective if needed for color blind users
<span><div class="Objective" style= 'background-color:{{ a_text.objective_background }}' title='{{ a_text.objective_color }}' aria-label='{{ a_text.objective_color }}'>
{{ a_text.objective_text|linebreaks}}<c>{{ a_text.objective_color }}</b> </div></span>-->
</a>
{% else %}
<!--Create pointed arrow and space to Outcome-->
<div class="space"></div>
<div class="triangle-right"></div>
<div class="spaceblank"></div>
<div class="item_Outcome_Name">
{{ a_text.objective_text|linebreaks}}</div>
{% endif %}
{% endif %}
{% endfor %}
{% endfor %}
</td>
</table>
<!--
{% if data_entry_button != 1 %}
<div class='outcometext'>Outcomes</div>
{% endif %}
-->
{% endblock %}