小编Zag*_*loo的帖子

CSS - 使用数据属性添加颜色 - attr(数据颜色)

我正在尝试使用我的css中的数据属性为不同的元素添加颜色但是不起作用...

我按照这个说明操作:

attr()函数:从编辑的文档中收集的属性值.

W3C

HTML

<table>
    <tr>
        <td>
            <span class="bgborder" data-color="#e7663f"></span>
            <i class="fa fa-copy"></i>
        </td>
        <td>
            <span>Blaablaaablaaa</span>
        </td>
    </tr>
</table>
<table>
    <tr>
        <td>
            <span class="bgborder" data-color="#77c385"></span>
            <i class="fa fa-upload fa-fw"></i>
        </td>
        <td>
            <span>Blablaablaaa</span>
        </td>
    </tr>
</table>
Run Code Online (Sandbox Code Playgroud)

CSS

.bgborder {
    display: block;
    width: 5px;
    height: 100%;
    position: absolute;
    top: 0;
    background-color: attr(data-color color);
}
Run Code Online (Sandbox Code Playgroud)

什么都没有出现......我是对的?

在我的chrome检查员中,我有这个:

background-color: attr(data-color color); 
/!\ Invalid property value
Run Code Online (Sandbox Code Playgroud)

我不明白为什么...... ???

谢谢你的帮助 :)

html css less twig

15
推荐指数
4
解决办法
3万
查看次数

Symfony - Twig - 过滤"localizeddate"在DateTime上不起作用

我正在使用树枝,当我应用过滤器时

{{tutoriel.dateCreation | localizeddate('medium', 'none') }} 在我的日期时间,我有这个错误:

The filter "localizeddate" does not exist in Video2LearnAdministrationBundle:VisualisationFicheTutoriel:fiche_tutoriel.html.twig at line 167
Run Code Online (Sandbox Code Playgroud)

哪里我错了?

谢谢 :)

symfony twig

10
推荐指数
2
解决办法
8013
查看次数

HtmlPurifier - 允许数据属性

我试图让一些人data-attribute使用htmlPurifier,span但我没办法......

我有这个字符串:

<p>
    <span data-time-start="1" data-time-end="5" id="5">
       <word class="word">My</word>
       <word class="word">Name</word>
    </span>
    <span data-time-start="6" data-time-end="15" id="88">
       <word class="word">Is</word>
       <word class="word">Zooboo</word>
    </span>
<p>
Run Code Online (Sandbox Code Playgroud)

我的htmlpurifier配置:

$this->HTMLpurifierConfigInverseTransform = \HTMLPurifier_Config::createDefault();
$this->HTMLpurifierConfigInverseTransform->set('HTML.Allowed', 'span,u,strong,em');
$this->HTMLpurifierConfigInverseTransform->set('HTML.ForbiddenElements', 'word,p');
$this->HTMLpurifierConfigInverseTransform->set('CSS.AllowedProperties', 'font-weight, font-style, text-decoration');
$this->HTMLpurifierConfigInverseTransform->set('AutoFormat.RemoveEmpty', true);
Run Code Online (Sandbox Code Playgroud)

$value像这样净化我:

$purifier = new \HTMLPurifier($this->HTMLpurifierConfigInverseTransform);
var_dump($purifier->purify($value));die;
Run Code Online (Sandbox Code Playgroud)

得到这个:

<span>My Name</span><span>Is Zoobo</span>
Run Code Online (Sandbox Code Playgroud)

但是,如何保护我的数据属性id,data-time-start,data-time-end在我的span

我需要这个:

<span data-time-start="1" data-time-end="5" id="5">My Name</span data-time-start="6" data-time-end="15" id="88"><span>Is Zoobo</span>
Run Code Online (Sandbox Code Playgroud)

我试着用这个配置测试:

$this->HTMLpurifierConfigInverseTransform->set('HTML.Allowed', 'span[data-time-start],u,strong,em');
Run Code Online (Sandbox Code Playgroud)

但错误信息:

用户警告:不支持元素"span"中的属性"data-time-start"(有关实现此信息的信息,请参阅支持论坛)

谢谢你的帮助 !!

编辑1

我尝试在这个代码行的firdt时间允许ID: …

php filter htmlpurifier

7
推荐指数
1
解决办法
2490
查看次数

Jquery - 使用索引在Array中推送多个值

我有几个相同的类("traduction")这个HTML:

<div>
    <div class="traduction" data-exist='yes' data-id-traduction="1">
        Blabla 1
    </div>
    <div class="traduction" data-exist='no' data-id-traduction="2">
        Blabla 2
    </div>
    <div class="traduction" data-exist='yes' data-id-traduction="3">
        Blabla 3
    </div>
    <div class="traduction" data-exist='no' data-id-traduction="4">
        Blabla 4
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

我需要的是这样一个数组:

array
    0
       content : 'Blabla 1'
       exist : 'yes'
       id : '1'
    1
       content : 'Blabla 2'
       exist : 'no'
       id : '2'
...
Run Code Online (Sandbox Code Playgroud)

我尝试使用array.push(values)但是数组中没有索引......我该怎么做?谢谢

arrays jquery

1
推荐指数
1
解决办法
1万
查看次数

Symfony - Twig - 动态变量 - 如何在循环中连接两个变量

我必须将两个变量连接在一起,旁边是 request.locale

我向你解释一下:

我有一个实体命名的Lexicon几个领域: wordFr,wordEn,definitionFr,definitionEn

我尝试做类似的事情来替换FrEn根据request.locale它但它不起作用:

             {% set locale = '' %}

             {% if app.request.locale == "fr" %}
                 {% set locale = 'Fr' %}
             {% else %}
                 {% set locale = 'En' %}
             {% endif %}

             {% for wordList in wordsList %}
                 <tr>
                     <td>{{ wordList.word~locale }}</td>
                     <td>{{ wordList.definition~locale }}</td>
                 </tr>
             {% endfor %}
Run Code Online (Sandbox Code Playgroud)

如何拥有{{ wordList.wordFr }}{{ wordList.wordEn }}根据语言环境(替换var localeby Fr或 …

concatenation symfony twig

0
推荐指数
1
解决办法
748
查看次数

标签 统计

twig ×3

symfony ×2

arrays ×1

concatenation ×1

css ×1

filter ×1

html ×1

htmlpurifier ×1

jquery ×1

less ×1

php ×1