I need help creating an h2 element with a double border. Here is my current HTML+CSS snippet:
h2.titulo {
width: 100%;
margin: 10px 0;
padding: 10px 0;
text-transform: uppercase;
font-weight: 400;
font-size: 30px;
display: block;
color: #8c2638;
border-bottom: 1px solid #ccc;
font-size: 25px;
}
h2.titulo span {
padding: 11px 0;
font-size: 19px;
font-size: 25px;
border-bottom: 1px solid #8c2638;
}
<h2 class="titulo"><span>My title</span></h2>
I want the title to be responsive, and when it's too long I'd like to use text-overflow: ellipsis with overflow:hidden. However, applying overflow hidden on h2 makes the red border disappear:
h2.titulo {
width: 100%;
margin: 10px 0;
padding: 10px 0;
text-transform: uppercase;
font-weight: 400;
font-size: 30px;
display: block;
color: #8c2638;
border-bottom: 1px solid #ccc;
font-size: 25px;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
h2.titulo span {
padding: 11px 0;
font-size: 19px;
font-size: 25px;
border-bottom: 1px solid #8c2638;
}
<h2 class="titulo"><span>A very very very very very very very very long long title</span></h2>
The closest solution I found still doesn't align the red border exactly with the other border:
h2.titulo {
border-bottom: 1px solid #ccc;
font-size: 25px;
width: 100%;
margin: 10px 0;
padding: 0;
text-transform: uppercase;
font-weight: 400;
font-size: 30px;
display: block;
color: #8c2638;
overflow-x: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
h2.titulo span {
display: inline-block;
line-height: 100%;
padding-bottom: 10px;
border-bottom: 1px solid #8c2638;
}
<h2 class="titulo"><span>Normal title</span></h2>
The trick of using margin-bottom:-1px; on span didn't work because of the overflow issue. Any suggestions please?