简体   繁体   English

如何样式类元素?

[英]how to style class element?

I have a js library on my website which is creating popups for me. 我的网站上有一个js库,正在为我创建弹出窗口。

Im trying to style the popups but nothing is working. 我正在尝试设置弹出窗口的样式,但没有任何效果。

the html output is 的HTML输出是

<div class="lpopup zoom" style="opacity: 1; transform: translate(435px, 200px); bottom: -6px; left: -54px;">

All that I have been trying to is change the bottom and left position. 我一直试图更改底部和左侧位置。

When I inspect with fire bug the css is 当我用萤火虫检查时,css是

element.style {
  bottom: -6px;
  left: -54px;
  opacity: 1;
  transform: translate(435px, 200px);
}

I have tried manipulating the css by doing 我已经尝试通过操作CSS

.lpopup, .lpopup zoom, .lpopup.style, lpopup element.style {
   bottom: 30px;
}

But none of them are working, I've tried as many variations as I can think of. 但是它们都不起作用,我尝试了尽可能多的变体。

I have also tried with js 我也尝试过js

$(".lpopup zoom").css("bottom", "30px");

and other variations 和其他变体

nothing happening though 没事

Im really struggling just trying to change the element style of a popup. 我真的很努力,只是尝试更改弹出窗口的元素样式。

Thanks for any help 谢谢你的帮助

The content in the style attribute is more specific then any rule-set, so it will always come last in the cascade and be applied. 样式属性中的内容任何规则集都更具体 ,因此它将始终排在级联的最后并被应用。

The clean solution is: Move the initial CSS out of the style attribute and into the stylesheet. 干净的解决方案是:将初始CSS移出style属性,然后移入样式表。 Then write your rules while paying attention to specificity. 然后在注意特定性的同时编写您的规则。

The hacky solution is: Use the !important flag hacky解决方案是:使用!important标志

The really nasty solution is: Use JavaScript to change the style attribute (which is what you are trying, but you have the selector wrong). 真正令人讨厌的解决方案是:使用JavaScript更改样式属性(这是您要尝试的,但是选择器错误)。

.lpopup zoom will match: <anything class="lpopup"><zoom> This element </zoom></anything> .lpopup zoom将匹配: <anything class="lpopup"><zoom> This element </zoom></anything>

You want .lpopup.zoom which will match an element that is members of both classes. 您需要.lpopup.zoom ,它将匹配两个类的成员的元素。

You need .lolup.zoom { css here } . 您需要.lolup.zoom { css here }

Sorry, I didn't fully comprehend the question like Mr. Alien did. 抱歉,我没有像Alien先生那样完全理解这个问题。 Yes, inline styles will always override external styles, so you either need to use !important (which I'd avoid), or remove the inline style if possible. 是的,内联样式将始终覆盖外部样式,因此您需要使用!important(我会避免),或者尽可能删除内联样式。

writing style in your own page wont works.... 在您自己的页面中书写样式将不起作用。

You just open your popup js library and change the style which are added throught the script... 您只需打开弹出式js库并更改通过脚本添加的样式即可。

It is very easy way to customize your popup design in js file.... 这是在js文件中自定义弹出窗口设计的非常简单的方法。

.lpopup {// css在这里} .zoom {// css在这里}应该存在于您的CSS文件中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM