2016-12-27 65 views
1

我使用ACF的WordPress,我需要使用自定義字段作爲CSS類的寬度。作爲CSS類的高級自定義字段

我創建了一個活力四射的風格與變量:

<?php header("Content-type: text/css"); 
$scala = get_field('scala'); 
?> 

#chart li .bar {  
height: 10px; 
background: #546a79; 
width: <?php echo $scala ; ?> } 

可惜我不能在網頁上看到的結果,但是如果我把一個精確值,那麼它的作品:

<?php header("Content-type: text/css"); 
$scala = '60%'; 
?> 

#chart li .bar {  
height: 10px; 
background: #546a79; 
width: <?php echo $scala ; ?> } 

顯然我已經在帖子中註冊了自定義值。

回答

0

您是否可以將自定義類添加到要用帖子上的自定義字段進行縮放的內容容器中。 Soemthing一樣,你可以設置爲「六十條」也許再有以下代碼下拉:

<div class="post-container <?php the_field('sixty'); ?>"> 

這將使格這個樣子的,上課的時候被激活:

<div class="post-container sixty"> 

而且然後像這樣設計:

.post-container.sixty { 
    width: 60% 
} 
相關問題