将样式属性迁移到分离的.css文件

时间:2015-11-28 16:41:58

标签: javascript html css optimization stylesheet

亲爱的社区成员,

我需要把所有:

    style="display:none" 

来自所有行:

    <p class="text" style="display:none"> 

到以下样式表:

    style.css 
<{3>}上的

值得注意的是,如果我搬家

    "display:none"

    .text 

in

    style.css 

比描述性标题不会分别改变页面上的图片滑动(即在网站屏幕两侧使用箭头)。

最后澄清:

我需要删除所有

    style="display:none" 

    <p class="text" style="display:none"> 

    .text 

at

    style.css. 

这将大大帮助我清理网站上的代码。完成更改后,html页面中的<p>标记将如下所示:

    <p class="text">

如果需要进一步说明,请在此帖子下面发表您的评论。

非常感谢您的帮助!

UPD:它还需要在JS中更改控制display:none的功能。如果你可以帮助我,请在下面发布: - )!

2 个答案:

答案 0 :(得分:0)

   /* style.css */
   /* set all `p` elements having `class` `"text"` 
      `display` property to `none`
   */
   p.text {
      display:none;
   }

答案 1 :(得分:0)

熟悉CSS的基础知识。 在你的情况下,你已经设置了一个课程&#34; text&#34;对所有相关对象。

您的CSS文件将包含类似

的内容
.text {
    display: none;
}

编辑:

您还需要将CSS文件链接到head-tag中的文档:

<link rel="stylesheet" type="text/css" href="mystyle.css" />

以下是一些基础知识:http://www.w3schools.com/css/css_howto.asp

要更改文字,您必须在箭头中添加一些javascript,以正确的方式设置display-properties:

document.getElementById("<the id of the current text>").display = "none";
document.getElementById("<the id of the next text>").display = "inline";

有关通过JS操作CSS的更多信息,请查看:http://www.w3schools.com/js/js_htmldom_css.asp