简体   繁体   English

是否可以在 TYPO3 中使用 Fluid 更改 CSS 属性和值?

[英]Is it possible to change CSS property and value using Fluid in TYPO3?

I want to adjust the height of some lines of texts by css-file.我想通过 css-file 调整一些文本行的高度。 But I can't change css property and value directly, because the contents are displayed with Fluid of TYPO3.但是我不能直接更改css属性和值,因为内容是用TYPO3的Fluid显示的。

This is my codes in a HTML-file:这是我在 HTML 文件中的代码:

<!-- for left side --> 
<div class="anreisetag-zeit anreisetagabstand">
   <f:for each="{anreisetag}" as="itemAnreisetag" iteration="iteration">
      {itemAnreisetag.data.tx_anreisetag_zeit -> f:format.html()}
   </f:for>                                
</div>
<!-- for right side --> 
<div class="anreisetag-text">
   <f:for each="{anreisetag}" as="itemAnreisetag" iteration="iteration">
     {itemAnreisetag.data.bodytext -> f:format.html()}
   </f:for>                                
</div>

Now my contents are displayed in frontend, but the height of the textline is different.现在我的内容显示在前端,但文本行的高度不同。 My problem now is:我现在的问题是:在此处输入图像描述

I want to adjust the height between the line of "anreisetag-zeit / anreisetagabstand" and "anreisetag-text", so that they have same height.我想调整“anreisetag-zeit / anreisetagabstand”和“anreisetag-text”行之间的高度,使它们具有相同的高度。

My idea: I have an idea that I add a field in Backend which it has a type="input" .我的想法:我有一个想法,我在后端添加一个字段,它有一个type="input" I added this:我添加了这个:在此处输入图像描述
The field has a variable tx_anreisetag_zeit_abstand .该字段有一个变量tx_anreisetag_zeit_abstand

Also, every item has class name like this:此外,每个项目都有这样的类名:
在此处输入图像描述

My final idea is that if I give a value in the input-field tx_anreisetag_zeit_abstand , then "margin-bottom" of the <p class="text-center"> is changed with the new value.我的最终想法是,如果我在输入字段tx_anreisetag_zeit_abstand中给出一个值,那么<p class="text-center">的“margin-bottom”会用新值更改。 Now anreisetagabstand p has "margin-bottom: 16px;".现在anreisetagabstand p有“margin-bottom: 16px;”。 I want to change these value "16px" for example to "38px" from Backend.我想将这些值“16px”从后端更改为“38px”。

in my CSS file now:现在在我的 CSS 文件中:

.anreisetagabstand p{
    margin-bottom: 16px;
}

The class anreisetag-text will be changed anything.anreisetag-text将被更改任何内容。 Just the style of "p element of anreisetag-zeit" or "anreisetagabstand" musst be changed.只是“anreisetag-zeit的p元素”或“anreisetagabstand”的样式必须改变。 I've already defined some design with the calssname "anreisetag-zeit", so I want to use the classname "anreisetagabstand" to adjust the hight.我已经用类名“anreisetag-zeit”定义了一些设计,所以我想使用类名“anreisetagabstand”来调整高度。

How can I realize this?我怎么能意识到这一点? If I don't use Fluid, then I can adjust easy...如果我不使用流体,那么我可以轻松调整...

Maybe can I change the css property and value from a JavaScript file to operate DOM?也许我可以更改 JavaScript 文件中的 css 属性和值来操作 DOM? I've already tried it, but I can't change my css property and value.我已经尝试过了,但我无法更改我的 css 属性和值。 I think there are some error in my codes:我认为我的代码中有一些错误:

window.onload = function() {
    var anreisetagzeit = document.getElementsByClassName('anreisetagabstand');
    anreisetagzeit += ' p';
    anreisetagzeit.style.marginBottom = '38px';
}

Adding:添加:

If I adjust my texts in my richt text editor, then I have to give some spaces and I have to check the frontend every time if the height or distance between the time and the description:如果我在我的富文本编辑器中调整我的文本,那么我必须给一些空格,并且我必须每次检查前端是否时间和描述之间的高度或距离:
在此处输入图像描述

Furthermore, I can't give spaces, if I use "list" in a rich text editor.此外,如果我在富文本编辑器中使用“列表”,我不能提供空格。 I have to give some space on the left side of the point to display the list-items on the right side :我必须在该点的左侧留出一些空间以在右侧显示列表项:
在此处输入图像描述

If I display them in frontend:如果我在前端显示它们:
在此处输入图像描述

I hope someone can give me some advices.我希望有人能给我一些建议。 Thank you.谢谢你。

trying to align your text and time to be on the same horizontal level is proably more easy by changing the HTML-structure instead of playing arount with linebreaks and CSS.通过更改 HTML 结构而不是使用换行符和 CSS 来尝试将文本和时间对齐到相同的水平水平可能更容易。

CSS-based solutions will maybe work on a static viewport, but as soon as the textarea grows or shrinks the number of lines of text will also change and therefore not be properly aligned again.基于 CSS 的解决方案可能会在静态视口上工作,但一旦 textarea 增长或缩小,文本行数也会发生变化,因此无法再次正确对齐。

If it is within your possibilities i would recommend to restructure your Template to something like this:如果它在您的可能性范围内,我建议您将您的模板重组为以下内容:

<div class="anreisetag-plan">
<f:for each="{anreisetag}" as="itemAnreisetag" iteration="iteration">
    <div class="anreise-item">
        <div class="anreisetag-zeit">
            {itemAnreisetag.data.tx_anreisetag_zeit -> f:format.html()}
        </div>
        <div class="anreisetag-text">
            {itemAnreisetag.data.bodytext -> f:format.html()}
        </div>
    </div>
</f:for>
</div>

With this structure you should be able to achieve your desired output alot more easy than before.使用这种结构,您应该能够比以前更容易地实现所需的输出。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM