[英]How do I make a CSS rule that only affects text but not the image?
I am using a php script that outputs the post like this:我正在使用一个 php 脚本来输出这样的帖子:
<div class="postoutput">
<p>
<img src="content/xeon.png" alt="xeon.png">
This is text, Xeon is great.```
</p>
</div>
I can't touch the output but I can modify the CSS, is there way to add a margin that ONLY applies to the text using only CSS我无法触摸输出,但我可以修改 CSS,有没有办法添加仅适用于仅使用 CSS 的文本的边距
The image is 100% wide and this is okay.图像是 100% 宽,这是可以的。
The desired goal is to keep the image as it is but make the text ONLY have a 10px margin on each side.所需的目标是保持图像原样,但使文本每边只有 10 像素的边距。 Remember, I only have access to the CSS file.
请记住,我只能访问 CSS 文件。
Long story short... no you cannot apply css directly to the text in your case.长话短说……不,您不能将 css 直接应用于您的案例中的文本。
You could probably emulate something close though.不过,您可能可以模仿一些接近的东西。
Assuming your image is fullwidth you could probably use something like:假设您的图像是全角,您可能会使用以下内容:
p {
padding:10px;
}
p > img {
margin:-10px -10px 10px;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.