css类属性动态变化

发布于 2024-12-26 12:16:53 字数 710 浏览 1 评论 0原文

我有一个基于 codeignter 的网站。我加载了这样的 css 文件:

<link href="<?php echo base_url();?>style/style.css" rel="stylesheet" type="text/css" />

这是该文件中的内容:

.forgot_password {
    color:#FF0000;
    font-weight:bold;
    margin-left:95px;
    margin-top:10px;
    display:none;
}
.forgot_message {
    display:none;
    font-size:13px;
    font-weight:bold;
    color:#C4ED10;
}

.enter_password_fr {
    color: #FFFFFF;
    font-size: 20px;
    font-weight: bold;
    margin-left: 100px;
}

然后我想检查 forgot_password 这个类是否存在于 css 文件中。如果它存在,那么我想更改 this (forgot_password) 类的颜色属性。我可以使用 php 执行此操作吗?

我怎样才能改变属性?这有可能吗?

I have a codeignter based site.In that i loaded the css file like this:

<link href="<?php echo base_url();?>style/style.css" rel="stylesheet" type="text/css" />

This is the content in that file:

.forgot_password {
    color:#FF0000;
    font-weight:bold;
    margin-left:95px;
    margin-top:10px;
    display:none;
}
.forgot_message {
    display:none;
    font-size:13px;
    font-weight:bold;
    color:#C4ED10;
}

.enter_password_fr {
    color: #FFFFFF;
    font-size: 20px;
    font-weight: bold;
    margin-left: 100px;
}

Then i want to check forgot_password this class exist in the css file.If it exists then i want to chnage the color attribute of the this (forgot_password) class.Can i do this using php?

How can i change the attribute?Is this possible by any way?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

初见你 2025-01-02 12:16:53

您可以在Javascript的帮助下更改它,并且您的问题可能有重复单击此处

希望这有帮助

You can change it with the help of the Javascript and there is the possible duplicate of your question please click here

Hope this helps

纵山崖 2025-01-02 12:16:53

您不能动态地将第二种样式添加到将覆盖颜色的元素吗?

.forgot_password_alt {color:#f00 !important;}

Couldn't you dynamically add a second style to the element that would override the color?

.forgot_password_alt {color:#f00 !important;}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文