简体   繁体   English

HTML中的造型导入元素

[英]Styling imported element in HTML

So currently I am importing text as an object tag as so:所以目前我将文本作为 object 标签导入,如下所示:

<object width="100%" height="500" data="M2History.txt" >

however when doing this, I currently am not getting any styles applied to the text, and its pasting into my site in a default format.但是,在执行此操作时,我目前没有将任何 styles 应用于文本,也没有以默认格式将其粘贴到我的网站中。 When it gets imported it does as: <pre style="word-wrap: break-word; white-space: pre-wrap;">当它被导入时,它的作用是: <pre style="word-wrap: break-word; white-space: pre-wrap;">

I tried to do styling on pre, but it doesn't seem to be doing anything.我试图在 pre 上做造型,但它似乎没有做任何事情。 Can someone help with this?有人可以帮忙吗? I have also tried to style other elements, such as body and object tags but to no avail.我也尝试过设置其他元素的样式,例如 body 和 object 标签,但无济于事。

You can add styles to an object element (not to it's inner content) with specific data attribute this way:您可以通过以下方式将 styles 添加到具有特定数据属性的object元素(而不是其内部内容):

data=["M2History.txt"] {
  border: 1px solid #000;
  margin: 20px;
}

You cannot access object's inner content because this is iFrame, so CSS has no power.你不能访问对象的内部内容,因为这是 iFrame,所以 CSS 没有权力。 Please, check this question , it could be helpful.请检查这个问题,它可能会有所帮助。 Good luck.祝你好运。 PS guide to data attributes here PS 数据属性指南在这里

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

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