2017-03-02 24 views
0

嘿,我正試圖在我的wordpress站點上應用flexbox。如何在我的Wordpress站點上添加flexbox

基於我所知道的Flexbox是「Flexible Box Layout Module」的縮寫,它是由萬維網聯盟(World Wide Web Consortium)標準化的CSS3模塊。

所以我不必安裝任何軟件,兼容的瀏覽器都支持它本身,但由於某種原因,它不會在我的網站工作:

目前我使用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不起作用?

預先感謝您。

+1

你爲什麼不接受任何問題的答案,因爲1/24 ? –

+0

哪個答案邁克爾? –

+1

自1/24開始,你已經詢問了10,而且沒有人接受答案。 –

回答

1

您的代碼有效。你可能不會在Flex盒子的瀏覽器測試: 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); 
} 
+0

我使用這個Chrome版本:http://prntscr.com/eex6ae –

+0

我使用Safari的屏幕截圖修改了答案。這不是預期的結果嗎? – Jed

+0

沒有。期望的結果是它們全都具有相同的盒子大小。 –

相關問題