Reputation:
I have a div block on the top of my website where I want to display a logo and some info, like telephone number etc.
Here you can take a look: https://jsfiddle.net/7f8gc17o/
I wanted the text (telephonenumber, emailaddress) to be vertically centered, so I did this:
.headerinfo {
height: 250px;
display: flex;
align-items: center;
}
This was working great, but when I now resize the window, the text wont break. It just will stay there and the logo gets really, really small. When a user has a small screen, I want to display the information below. Logo on the top, followed by the information.
Secondly, what I have noticed: I have some kind of a headline (which I added the class "skyblue") - when I resize the window, the second text-line ("Hier finden Sie uns") breaks. But I want the headlines displayed next to each other, as long as there is enough space.
How do I do that? Help would be really appreciated.
Thank you for reading
Upvotes: 0
Views: 361
Reputation: 299
To centre the image, apply this style to it:
margin:0 auto
To centre the text, apply this style to it:
text-align: center
Upvotes: 0
Reputation: 9731
Try using Media Queries. And change the flex-direction
to column
on mobile. Like:
/* On Mobiles */
@media screen and (max-width: 767px) {
.headerinfo {
flex-direction: column;
}
}
Have a look at the snippet below:
@import url('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css');
@color-purple: #292657;
.purple-container,.headline-container{
width: 100%;
height: auto;
padding: 0;
background-color: @color-purple;
div.icon-container{
padding-bottom: 80px;
padding-top: 60px;
h2{
margin-bottom: 60px;
}
.thumbnail{
background-color: transparent;
border: none;
border-radius: 0;
>img{
width: 100%;
height: auto;
}
>.caption{
color: @color-white;
text-align: center;
text-transform: uppercase;
margin-top: 30px;
}
}
.text-container{
width: 80%;
height: auto;
margin-left: auto;
margin-right: auto;
margin-top: 60px;
margin-bottom: 40px;
>p{
>.bold{
font-weight: bold;
}
}
}
}
}
.font-bigger{
font-size:18px;
}
.skyblue{
color: #d2e5e9;
font-size: 20px;
}
/*this causes the main problem*/
.headerinfo {
height: 250px;
display: flex;
align-items: center;
}
/* On Mobiles */
@media screen and (max-width: 767px) {
.headerinfo {
flex-direction: column;
}
.logo-img {
margin: 20px 0 10px;
}
}
<div class="container purple-container text-center" style="margin:0 auto;">
<div class="container">
<div class="row headerinfo">
<div class="col-md-6">
<img class="logo-img" src="../img/Andreas_Heinke_Logo.png" alt="Some picture" style="width:auto;height:auto;max-width:100%;"/>
</div>
<div class="col-md-3 font-bigger">
<strong class="skyblue">Wir beraten Sie gern:</strong><br>
<span class="glyphicon glyphicon-earphone icon-margin"></span>01234 567 89 012<br>
<span class="glyphicon glyphicon-envelope icon-margin"></span>info@email.de
</div>
<div class="col-md-3 text-center font-bigger">
<strong class="skyblue">Hier finden Sie uns:</strong><br>
Streetname<br>
01234 City
</div>
</div>
</div>
</div>
Hope this helps!
Upvotes: 2