将内部样式表转换为内联CSS [英] Convert internal stylesheet to inline css

查看:390
本文介绍了将内部样式表转换为内联CSS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将内部样式表转换为内嵌CSS的页面,而无需使用任何在线来源。
我有风格定义为

how can i convert internal stylesheet to inline css of a page without using any online source. I have style defined as

<style  id="custstyle" type="text/css">
            .column{
                font-size:13px;
                font-family:arial, helvetica, verdana, sans-serif;
                font-weight:normal;
                color:rgb(221, 221, 221);
                font-size:13px;
                font-family:arial, helvetica, verdana, sans-serif;
                font-weight:normal;
                color:rgb(221, 221, 221);
            }
        </style> 

这为

<div id="sidebar-right" class="column">Content</div>

但我想将所有内部css自动转换为inline css

but i want to convert all internal css automatically to inline css

推荐答案

选择所有具有类的div,如果有,则应用inline CSS使用jquery。

select all the div that has the column class and remove class column if it is there then apply inline CSS using jquery.

$(document).ready(function(){
var obj = $(".column");
$(obj).each(function(){
    $(this).removeClass("column");//not really necessary
    $(this).css({"font-size":"13px","font-family":"arial,helvetica, verdana, sans-serif",          
            "font-weight":"normal",
            "color":"rgb(221, 221, 221)",
            "font-weight":"normal"});
});
});

工作小提琴

Working Fiddle

这篇关于将内部样式表转换为内联CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆