jquery - 如何忽略网站某些部分的 CSS img 样式?

标签 jquery css jquery-selectors

我需要一些帮助,最好是 jquery 片段。我们正在寻找的代码片段将允许我们忽略同一页面中的某些 css 类。

EX) 我们有 Header 标志 img 并且我们想忽略 img 的 css 样式,这如何实现?

CSS

img {
  position: absolute;
  top: 50%;
  left: 35%;
  width: 320px;
  height: 240px;
  transform: translateZ(.25px) scale(.75) translateX(-94%) translateY(-100%) rotate(2deg);
  padding: 10px;
  border-radius: 5px;
  background: rgba(240,230,220, .7);
  box-shadow: 0 0 8px rgba(0, 0, 0, .7);
}

我们想忽略第一个 img 的 css 样式并保留第二个 img 的样式,这是最好的方法吗?

最佳答案

你可以这样做:-

img:not(:first-child){
  position: absolute;
  top: 50%;
  left: 35%;
  width: 320px;
  height: 240px;
  transform: translateZ(.25px) scale(.75) translateX(-94%) translateY(-100%) rotate(2deg);
  padding: 10px;
  border-radius: 5px;
  background: rgba(240,230,220, .7);
  box-shadow: 0 0 8px rgba(0, 0, 0, .7);
}

Demo

关于jquery - 如何忽略网站某些部分的 CSS img 样式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25657611/

相关文章:

javascript - 使用 DOM 创建跨度

html - 文本区域滚动条 Firefox 错误

html - CSS 下拉过渡不起作用

jquery - $ ("#content a:not(target=_blank)") 不起作用..我做错了什么?

javascript - Chrome 扩展 "Refused to load the script because it violates the following Content Security Policy directive"

jquery - 强制 <li >'s width to be the same as it' s 内容

javascript - 使用 jQuery 和 CSS 创建多个生成的粘性 header 时遇到问题

鼠标悬停时姐妹 div 的 JavaScript style.height

javascript - 如何将 html 附加到所选元素后第一次出现的字符串

jquery - 如何查找符合多个条件的元素