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.
我的网站上有一个div块,我想要显示一个logo和一些信息,比如电话号码等。
Here you can take a look: https://jsfiddle.net/7f8gc17o/
这里您可以看一下:https://jsfiddle.net/7f8gc17o/。
I wanted the text (telephonenumber, emailaddress) to be vertically centered, so I did this:
我想让文本(telephonenumber, emailaddress)垂直居中,所以我这样做了:
.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.
其次,我注意到:我有一个标题(我添加了“skyblue”)——当我调整窗口大小的时候,第二个文本行(“Hier finden Sie uns”)会中断。但我想把标题放在旁边,只要有足够的空间。
How do I do that? Help would be really appreciated.
我该怎么做呢?非常感谢你的帮助。
Thank you for reading
感谢您的阅读
2 个解决方案
#1
3
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!
希望这可以帮助!
#2
0
To centre the image, apply this style to it:
为中心形象,应用这种风格:
margin:0 auto
保证金:0汽车
To centre the text, apply this style to it:
为中心文本,应用这种风格:
text-align: center
text-align:中心
#1
3
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!
希望这可以帮助!
#2
0
To centre the image, apply this style to it:
为中心形象,应用这种风格:
margin:0 auto
保证金:0汽车
To centre the text, apply this style to it:
为中心文本,应用这种风格:
text-align: center
text-align:中心