html - 如何在我的 Wordpress 网站上添加 flexbox

标签 html wordpress css flexbox

大家好,我正在尝试在我的 wordpress 网站上应用 flexbox。

据我所知,Flexbox 是“Flexible Box Layout Module”的简写,它是一个 CSS3 模块,由万维网联盟标准化。

所以我不需要安装任何东西,兼容的浏览器本身就支持它,但由于某些原因它不能在我的网站上运行:http://americanbitcoinacademy.com/course-list/

目前我在我的代码上使用 flex:

<div class="flex">
<div class="col-1-3">

<img src="http://americanbitcoinacademy.com/wp-content/uploads/2017/01/The-Bitcoin-Transaction-Landscape.jpg" />
<h3 style="text-align: center;">BC 101 - The Bitcoin Transaction COURSE</h3>
<p>This course covers the basics of what Bitcoin is and how the Blockchain works, how to use a Bitcoin Wallet and why Bitcoin is important.</p>
<a href="https://xt348.infusionsoft.com/app/orderForms/The-Bitcoin-Transaction" target="_blank"><button class="btn btn-block btn-primary">PURCHASE COURSE &rarr;</button></a>

</div>

</div>


.col-1-3 {
  padding: 10px;
  width: 28%;
  float: left;
margin: 2.5%;
 border: 1px solid #dedede;
-webkit-border-radius: 7px;
-moz-border-radius: 7px;
border-radius: 7px;
padding-bottom: 0px;
font-family: 'Lato', Verdana;
}
.col-1-3 img {
  width: 100%;
}
.col-1-3 img {
  width: 100%;
}
a {
  margin: 0;
}
h3 {
  margin: 15px auto;
font-size: 16px;
font-weight: bold;
text-transform: uppercase;
}

p{
line-height: 16px;
margin: 10px auto;
}
h4 {
  margin: 0 0 20px 0;
}

}
.btn-block {
  display: block;
  width: 100%;
margin-top: 22px;
background: #DD374D;
}

button.btn-block{
background: #DD374D;
font-family: 'Roboto';
margin-bottom: 10px;
font-weight: bold;
}

}
@media only screen and (max-width: 767px) {
  .col-1-3 {
    width: 44%;
  }
}
@media only screen and (max-width: 590px) {
  .col-1-3 {
    width: 94%;
  }
}

.flex {
  display: flex;
  flex-wrap: wrap;
}

无论默认情况下该页面上的内容有多长,这都可以使框的大小相等。 知道为什么 flexbox 不起作用吗?

提前谢谢你。

最佳答案

您的代码有效。您可能没有在支持 flex box 的浏览器中进行测试: http://caniuse.com/#search=flexbox

enter image description here

将按钮对齐到底部:

.col-1-3 {
  position: relative;
  padding-bottom: 40px; /* offset height of button */
}
button.btn-block{
  position: absolute;
  bottom: 0px;
  width: calc(100% - 20px);
}

关于html - 如何在我的 Wordpress 网站上添加 flexbox,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42545380/

相关文章:

html - 单击后保持按钮样式

html - 转换未被子树和属性断点捕获 Chrome 开发人员工具

Jquery 显示/隐藏图片点击

Facebook 分享按钮内部服务器错误

ios - 如何将我的 WordPress 博客整合到 iOS 应用程序中?

javascript - 网站上的标签 html 遇到问题

php - 根据高度保持纵横比

javascript - 如果源为空,如何将 id 为 false 的 img 标签设置为 false?

javascript - AngularJS 输入字段未从 Controller 内的 setTimeout 更新

php - 如何在 WooCommerce 中使用 add_to_cart() 方法?