admin管理员组文章数量:1130349
The goal is to add some internal styles to a function. The function has some if statements, and then it does:
$content .= "
<div>
<h3>stuff</h3>
<div>$additional_stuff</div>
</div>";
endwhile;
I'd like to put some styles
in there, too, so it loads when the h3 and additional_stuff loads, but my attempts ways just break it.
The goal is to add some internal styles to a function. The function has some if statements, and then it does:
$content .= "
<div>
<h3>stuff</h3>
<div>$additional_stuff</div>
</div>";
endwhile;
I'd like to put some styles
in there, too, so it loads when the h3 and additional_stuff loads, but my attempts ways just break it.
Share Improve this question edited Oct 21, 2018 at 14:27 Tiago Peres 951 gold badge1 silver badge11 bronze badges asked Oct 20, 2018 at 17:25 Justin MunceJustin Munce 31 bronze badge1 Answer
Reset to default 0Here's couple of examples on how to add styling to your code.
// Method 1. define classes in another variable, then do styling in styles.css
$classes = 'another-class';
$content .= "
<div id=\"my-id\"class=\"my-class\"> // Method 2. use backslashes to escape double quotes and add id and classes as needed, then do styling in styles.css
<h3 class=\"{$classes}\">stuff</h3> // Method 1. interpolate classes where needed
<div style=\"background-color: blue; color: #fff;\">{$additional_stuff}</div> // Method 3. use backslashes to escape double quotes and add inline styles
</div>";
p.s. do remove the comments from the example code before copy-pasting $content to production.
The goal is to add some internal styles to a function. The function has some if statements, and then it does:
$content .= "
<div>
<h3>stuff</h3>
<div>$additional_stuff</div>
</div>";
endwhile;
I'd like to put some styles
in there, too, so it loads when the h3 and additional_stuff loads, but my attempts ways just break it.
The goal is to add some internal styles to a function. The function has some if statements, and then it does:
$content .= "
<div>
<h3>stuff</h3>
<div>$additional_stuff</div>
</div>";
endwhile;
I'd like to put some styles
in there, too, so it loads when the h3 and additional_stuff loads, but my attempts ways just break it.
Share Improve this question edited Oct 21, 2018 at 14:27 Tiago Peres 951 gold badge1 silver badge11 bronze badges asked Oct 20, 2018 at 17:25 Justin MunceJustin Munce 31 bronze badge1 Answer
Reset to default 0Here's couple of examples on how to add styling to your code.
// Method 1. define classes in another variable, then do styling in styles.css
$classes = 'another-class';
$content .= "
<div id=\"my-id\"class=\"my-class\"> // Method 2. use backslashes to escape double quotes and add id and classes as needed, then do styling in styles.css
<h3 class=\"{$classes}\">stuff</h3> // Method 1. interpolate classes where needed
<div style=\"background-color: blue; color: #fff;\">{$additional_stuff}</div> // Method 3. use backslashes to escape double quotes and add inline styles
</div>";
p.s. do remove the comments from the example code before copy-pasting $content to production.
本文标签: cssHow to add styles in existing function
版权声明:本文标题:css - How to add styles in existing function? 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749244735a2338685.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论