将嵌入的CSS移动到单独的CSS文件中

时间:2023-01-23 20:30:02

I want to remove the following from an html page and add it to an existing css sheet. Do I have to do anything special like creating a new .mynewclass or simply remove the <style> tags?

我想从html页面中删除以下内容,并将其添加到现有的css页面中。我是否需要做一些特别的事情,比如创建一个新的.mynewclass或者简单地删除

<style>
    <!--
    .rightAlign
    {
       text-align:right;
    }

    .leftPad05em
    {
       padding-left:0.5em;
    }

    .bottomPad05em
    {
       padding-bottom:0.5em;
    }

    .topPad05em
    {
       padding-top:0.5em;
    }

    .topBottomPad1em
    {
       padding:1em 0em 1em 0em;
    }

    .bottomControl
    {
       padding-left:14.5em;
    }
    -->
</style>

3 个解决方案

#1


4  

add your styles to a external stylesheet for example - default.css

将样式添加到外部样式表中,例如default.css

Include these in that stylesheet -

在样式表中包括这些-

.leftPad05em { padding-left:0.5em; }
.bottomPad05em { padding-bottom:0.5em; }
.topPad05em { padding-top:0.5em; }
.topBottomPad1em { padding:1em 0em 1em 0em; }
.bottomControl { padding-left:14.5em; }

and in your header include this -

在你的标题中包括这个-

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

<链接的href = "违约。css样式表" rel=" " type=" text / css ">

This is calling the default.css style sheet. Note, href="value" would be where the style sheet is located

这是在调用默认值。css样式表。注意,href="value"将位于样式表所在的位置

#2


0  

In this case it sufficient to write the embedding css code in your CSS file. Check if the classes already exist. If so, add the CSS atributes to these classes otherwise paste the code into the file.

在这种情况下,在css文件中编写嵌入css代码就足够了。检查类是否已经存在。如果是,将CSS atributes添加到这些类中,否则将代码粘贴到文件中。

#3


0  

If the existing CSS file is already imported in the HTML, then moving the inline CSS from the HTML to the file should work.

如果已经在HTML中导入了现有的CSS文件,那么将内联CSS从HTML移动到文件应该可以工作。

#1


4  

add your styles to a external stylesheet for example - default.css

将样式添加到外部样式表中,例如default.css

Include these in that stylesheet -

在样式表中包括这些-

.leftPad05em { padding-left:0.5em; }
.bottomPad05em { padding-bottom:0.5em; }
.topPad05em { padding-top:0.5em; }
.topBottomPad1em { padding:1em 0em 1em 0em; }
.bottomControl { padding-left:14.5em; }

and in your header include this -

在你的标题中包括这个-

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

<链接的href = "违约。css样式表" rel=" " type=" text / css ">

This is calling the default.css style sheet. Note, href="value" would be where the style sheet is located

这是在调用默认值。css样式表。注意,href="value"将位于样式表所在的位置

#2


0  

In this case it sufficient to write the embedding css code in your CSS file. Check if the classes already exist. If so, add the CSS atributes to these classes otherwise paste the code into the file.

在这种情况下,在css文件中编写嵌入css代码就足够了。检查类是否已经存在。如果是,将CSS atributes添加到这些类中,否则将代码粘贴到文件中。

#3


0  

If the existing CSS file is already imported in the HTML, then moving the inline CSS from the HTML to the file should work.

如果已经在HTML中导入了现有的CSS文件,那么将内联CSS从HTML移动到文件应该可以工作。