作为CSS类的高级自定义字段

问题描述:

我使用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 ; ?> } 

显然我已经在帖子中注册了自定义值。

您是否可以将自定义类添加到要用帖子上的自定义字段进行缩放的内容容器中。 Soemthing一样,你可以设置为“六十条”也许再有以下代码下拉:

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

这将使格这个样子的,上课的时候被激活:

<div class="post-container sixty"> 

而且然后像这样设计:

.post-container.sixty { 
    width: 60% 
}