是否可以应用于scroll-snap嵌套在应用了溢出的子级中的孙子级?我似乎无法让它发挥作用。
我的目标是有一个列表,div每个列表都有一个固定高度,视口应该垂直对齐
html {
margin: 0;
scroll-snap-type: y mandatory;
overflow-x: hidden;
}
.horizontal-scroll {
max-width: 100vw;
}
.child {
width: 150vw;
scroll-snap-align: center;
height: 80vh;
background-color: rgb(143, 204, 241);
padding: 20px 15px;
}
.child:nth-child(even) {
background-color: rgb(133, 243, 155);
}Run Code Online (Sandbox Code Playgroud)
<!DOCTYPE html>
<html>
<head
</head>
<body>
<div class="horizontal-scroll">
<div class="child">
<h2>Section</h2>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Vel laboriosam cupiditate vero, harum, ab facere ipsa mollitia exercitationem impedit alias nulla magnam aut tempore …Run Code Online (Sandbox Code Playgroud)我目前正在参与一个在 API 中使用 JMS Serializer 的项目。我们使用了很多虚拟属性——尤其是序列化映射中的表达式 Prop。
App\Entity\MyEntity:
exclusion_policy: none
properties:
id:
expose: true
groups: ['default']
virtual_properties:
child:
exp: object.getChildObject().getIdentifier()
serialized_name: child_identifier
type: string
groups: ['default']
amount:
exp: object.getOtherChild().getAmount()
serialized_name: other_child_amount
type: string
groups: ['default']
Run Code Online (Sandbox Code Playgroud)
这将允许我拥有子属性,而不必为更简洁的 JSON 创建 getter - 对于这些虚拟属性中有一些逻辑的情况非常有用(例如:以下示例中的“金额”)
{
"id": 123,
"child": "Identifier_52",
"amount": 100
}
// instead of
{
"id": 123,
"child": { "identifier" : "Identifier_52" }
"amount": { "weight": 20, "number": 5 }
}
Run Code Online (Sandbox Code Playgroud)
我们最近考虑切换到Symfony Serializer,到目前为止我还没有找到一种简单的方法来重用或重新实现这些配置(表达式)。如果我将属性 …
php serialization symfony jmsserializerbundle jms-serializer
我知道如何在 TWIG 中获取字符串的第一个字母
<p>The first letter is {{someString | first}}</p>
Run Code Online (Sandbox Code Playgroud)
使用 HTML 字符串,例如
<p>This is a sting</p>
Run Code Online (Sandbox Code Playgroud)
以上将返回'<'
添加 'Raw'/'escape' 会得到相同的结果。
我需要将该字符串显示为 HTML(与 Raw 类似),但获取第一个字母(在上述情况下为“T”)。
我是否以错误的顺序使用过滤器?
有谁知道 ?
非常感谢
@Matteo 的回答已经很接近了,但并不完全是我想要的。我可能错误地表述了我的问题。对不起。
所以如果我有这样的字符串
<p>This is a <strong>string</strong></p>
Run Code Online (Sandbox Code Playgroud)
使用 raw 会给
这是一个字符串
现在我真正需要的是让第一个字母 (T) 用它做一些事情,比如在它周围添加标签
<span>T</span>his is a <strong>string</string>
Run Code Online (Sandbox Code Playgroud)
同时仍将其余的 HTML 保留在 . Striptags 删除字符串中的所有标签并返回一个没有 HTML 部分的纯字符串。我希望我的表述是正确的。