CSS Bootstrap - 文本没有正确破坏

时间:2016-12-19 13:51:26

标签: html css twitter-bootstrap

我的网站顶部有一个div块,我想显示一个徽标和一些信息,比如电话号码等。

您可以在此处查看:https://jsfiddle.net/7f8gc17o/

我希望文本(telephonenumber,emailaddress)垂直居中,所以我这样做了:

.headerinfo {
  height: 250px;
  display: flex;
  align-items: center;
}

这很有效,但是当我现在调整窗口大小时,文本不会破坏。它只会留在那里,徽标真的很小。当用户的屏幕较小时,我想显示以下信息。顶部有徽标,后面是信息。

其次,我注意到了:我有一些标题(我添加了类" skyblue") - 当我调整窗口大小时,第二个文本行(" Hier Finden Sie uns")休息。但是,只要有足够的空间,我希望标题显示在彼此旁边。

我该怎么做?帮助将非常感激。

感谢您阅读

2 个答案:

答案 0 :(得分:3)

尝试使用媒体查询。并在移动设备上将flex-direction更改为column。像:

/* On Mobiles */
@media screen and (max-width: 767px) {
  .headerinfo {
    flex-direction: column;
  }
}

请看下面的代码段:



@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>
&#13;
&#13;
&#13;

希望这有帮助!

答案 1 :(得分:0)

要使图像居中,请将此样式应用于该图像:

保证金:0自动

要使文本居中,请将此样式应用于该文本:

text-align:center

相关问题