img[src=""],img:not([src]){ opacity:0; }在ext中怎么改写
时间: 2024-03-09 13:47:41 浏览: 19
在Ext中,可以使用以下方式将CSS选择器应用到元素上:
1. 使用 Ext.ComponentQuery.query() 方法查询元素,然后使用元素的 addCls() 和 removeCls() 方法来添加和移除CSS类。
例如,下面的代码将选择器 `img[src=""],img:not([src])` 应用到所有名为 `myImage` 的元素上:
```
Ext.ComponentQuery.query('myImage').forEach(function(el) {
if (el.dom.src || el.dom.hasAttribute('src')) {
el.removeCls('myImage-hidden');
} else {
el.addCls('myImage-hidden');
}
});
```
2. 使用 Ext.dom.Query.select() 方法查询元素,然后使用元素的 setStyle() 方法来设置样式。
例如,下面的代码将选择器 `img[src=""],img:not([src])` 应用到所有名为 `myImage` 的元素上:
```
Ext.dom.Query.select('img[src=""],img:not([src])', true).forEach(function(el) {
if (el.dom.src || el.dom.hasAttribute('src')) {
el.setStyle('opacity', 1);
} else {
el.setStyle('opacity', 0);
}
});
```
注意,第二个参数 `true` 表示查询所有符合条件的元素,而不是仅查询第一个符合条件的元素。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
<!DOCTYPE html> <html> <hand> <style> .out{ width: 1460px; height: 750px; border:1px solid #BFBFBF; margin: 20px auto; box-shadow:0px 0px 10px 5px #8e8c8c; } h1{ color:black; text-align: center; font-family: "字魂4086号-雅宋漂泊体"; font-size: 75px; } .slideshow-container { max-width: 1000px; position: relative; margin: auto; } .mySlides { display: none; } .prev,.next { cursor: pointer; position: absolute; top: 50%; width: auto; padding: 16px; margin-top: -22px; color: white; font-weight: bold; font-size: 18px; transition: 0.6s ease; border-radius: 0 3px 3px 0; user-select: none; } .next { right: 0; border-radius: 3px 0 0 3px; } .prev:hover,.next:hover { background-color: rgba(0, 0, 0, 0.8); } .fade { animation-name: fade; animation-duration: 1.5s; } @keyframes fade { from { opacity: 0.4; } to { opacity: 1; } } </style> <script> var slideIndex = 1; showSlides(slideIndex); function plusSlides(n) { showSlides((slideIndex += n)); } function currentSlide(n) { showSlides((slideIndex = n)); } function showSlides(n) { var i; var slides = document.getElementsByClassName("mySlides"); var dots = document.getElementsByClassName("dot"); if (n > slides.length) { slideIndex = 1; } if (n < 1) { slideIndex = slides.length; } for (i = 0; i < slides.length; i++) { slides[i].style.display = "none"; } for (i = 0; i < dots.length; i++) { dots[i].className = dots[i].className.replace(" active", ""); } slides[slideIndex - 1].style.display = "block"; dots[slideIndex - 1].className += " active"; } </script> </hand> <body> 甘肃美食介绍
❮ ❯ </body> </html>这段代码为什么运行的时候没有轮播图?哪里有问题,正确的代码是怎样的?
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>个人介绍</title> <style> /* 样式表 */ /* 轮播图区域 */ .slideshow { position: relative; width: 100%; height: 300px; overflow: hidden; } .slideshow img { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 1s ease-in-out; } .slideshow img.active { opacity: 1; } /* 导航栏区域 */ nav { background-color: #333; color: #fff; display: flex; justify-content: space-between; padding: 10px; } nav a { color: #fff; text-decoration: none; margin: 0 10px; } </style></head><body> 首页 关于我 联系我
欢迎来到我的个人网站 我叫XXX,是一名XXX。我喜欢XXX,平时喜欢XXX。欢迎联系我,我的邮箱是XXX。 <script> // 轮播图部分的脚本 var images = document.querySelectorAll('.slideshow img'); var currentImageIndex = 0; var slideshowInterval = setInterval(nextImage, 3000); function nextImage() { images[currentImageIndex].classList.remove('active'); currentImageIndex = (currentImageIndex + 1) % images.length; images[currentImageIndex].classList.add('active'); } </script></body></html>你这个代码图片显示不完全,如何完整显示图片
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)