【问题标题】:Definition css style div element定义css样式的div元素
【发布时间】:2016-12-21 06:46:34
【问题描述】:

我使用 javascript,我有以下元素。我想应用 CSS 样式来更改高度:元素 iframe 的 100px

<div tabindex="-1" 
class="mce-edit-area mce-container mce-panel mce-stack-layout-item"
 id="mceu_21" role="group" style="border-width: 1px 0px 0px;" hidefocus="1">
 <iframe title="Área de texto enriquecido. 
 Pulse ALT-F9 para el menu. Pulse ALT-F10 para la barra de herramientas.
 Pulse ALT-0 para ayuda" id="text1_ifr" src='javascript:""' 
 frameborder="0" style="width: 100%; height: 100px; display: block;" allowtransparency="true">
</iframe></div>

如何定义 CSS 样式?

【问题讨论】:

  • 你想改变 iFrame 的高度并只搜索命令来使用 javascript 执行此操作吗?
  • 您是否尝试使用属性 height = "100" ?
  • 我想应用一个 CSS 样式

标签: javascript css styles


【解决方案1】:

先给 iframe 添加一个类

<iframe class="height-100"></iframe>

在 CSS 中提供您的样式,

iframe .height-100 {
  height: 100px;
}

仅在不得已的情况下使用height: 100px !important

更新:

您已经为 iframe 提供了样式

style="width: 100%; height: 100px;"

这应该有效,使用element select 并检查它是否被其他东西覆盖。

【讨论】:

    【解决方案2】:

    在head标签中定义样式元素

    <style>
    iframe {
        width: 100px !important;
    }
    </style>
    

    【讨论】:

    • 如何定义元素 id="mceu_21" 的样式?
    • @user3712581 你必须在 id 前面使用 # ,检查 css selectors
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-12-21
    • 1970-01-01
    • 2014-01-15
    • 2011-09-26
    • 1970-01-01
    • 1970-01-01
    • 2015-07-17
    相关资源
    最近更新 更多