首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >为什么在显示: inline-block时背景色不能对齐?

为什么在显示: inline-block时背景色不能对齐?
EN

Stack Overflow用户
提问于 2020-06-04 02:55:53
回答 1查看 36关注 0票数 1

我很抱歉,如果我遗漏了一些明显的东西,但我不知道为什么它不像我的页面上的其他东西一样抓拍。

代码语言:javascript
运行
复制
body {
  background-color: #e9e9e9 !important;
}

.featured-products {
  display: inline-block;
  background-color: white;
}

.featured-header {
  font-size: 1rem !important;
  margin-top: 50px;
  margin-left: 340px;
  margin-right: 340px;
  color: #3c1c64;
  display: inline-block;
}
代码语言:javascript
运行
复制
	<div class="featured-products">
		<h2 class="featured-header"><strong>Try our newest creation, the Quaruntine Cookie Pack with our most famous flavors!</strong></h2>
	</div>

EN

回答 1

Stack Overflow用户

发布于 2020-06-04 03:32:41

下面的代码是您所期望的吗?

代码语言:javascript
运行
复制
body {
  background-color: #e9e9e9 !important;
}

.featured-products {
  max-width: 500px;
  width: 100%; /* To make sure it will size correctly on smaller screens */
  padding: 25px;
  margin: 0 auto;
  display: block;
  background-color: white;
}

.featured-header {
  margin: 0;
  font-size: 1rem;
  color: #3c1c64;
  display: inline-block;
}
代码语言:javascript
运行
复制
<div class="featured-products">
  <h2 class="featured-header"><strong>Try our newest creation, the Quaruntine Cookie Pack with our most famous flavors!</strong></h2>
</div>

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62180605

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档