


各位大侠,以下虽然定义了两个样式,但样式二却包含了样式一了,也就是样式二的那个
- 除了执行样式二之外,还同时执行了样式一,我想让他们两个独立,不相互包容,怎么改呢?
样式一图
样式二图
样式一:不修改这里
---------------------------------------------------------------------------------------------
样式二:这里跟上面重复样式,如何修改
Reply to discussion (solution)
Is it the effect after clicking, what about js? Post it
<script></script>
<script></script>
<script> <br /> function selectTag(showContent,selfObj){ <br /> var tag = document.getElementById("tags").getElementsByTagName("li"); <br /> var taglength = tag.length; <br /> for(i=0; i<taglength; i ){ <br /> tag[i].className = ""; <br /> } <br /> selfObj.parentNode.className = "selectTag"; <br /> for(i=0; j=document.getElementById("tagContent" i); i ){ <br /> j.style.display = "none"; <br /> } <br /> document.getElementById(showContent).style.display = "block"; <br /> } <br /> </script>
<script> <br /> window.onload=function(){ <br /> var size = new Select("size",{ <br /> Radio :true , <br /> OnClick:function(selected){ <br /> document.form.size.value = selected.join(",") <br /> document.form.color.value=''; <br /> } <br /> }); <br /> } <br /> </script>
<script> <br /> $(function() { <br /> $('#tabs').tabs(); <br /> }); <br /> </script>
|
<script> <br /> function Select(id,config){ <br /> this.config = config||{}; <br /> this.id = typeof(id)=='string'?document.getElementById(id):id; <br /> this.items = this.id.getElementsByTagName("li"); <br /> this.selectClass = "select"; <br /> this.selected = new Array(); <br /> var _this = this; <br /> this.selectOpt = function(value,opt){ <br /> var exist = false; <br /> for(var i=0;i<_this.selected.length;i ){ <br /> if(_this.selected[i]==value){ <br /> exist = true ; <br /> if(opt=="remove"){ _this.selected.splice(i,1);} <br /> break; <br /> } <br /> } <br /> if(!exist && opt=="add"){_this.selected.push(value);} <br /> }; <br /> //初始化对象 <br /> (function(_this){ <br /> //是否有默认配置的选择项 <br /> if(_this.config.Default){ <br /> var arr = _this.config.Default.split(","); <br /> for(var i=0;i<arr.length;i )_this.selectOpt(arr[i],"add"); <br /> } <br /> for(var i=0;i<_this.items.length;i ){ <br /> //将defalut中配置的项加上样式 <br /> if( _this.selected.join(",").indexOf(_this.items[i].getAttribute('dataValue'))>-1 && _this.items[i].className==""){ <br /> _this.items[i].className=_this.selectClass; <br /> } <br /> //如果有样式中定义了默认 <br /> if(_this.items[i].className==_this.selectClass){ <br /> _this.selectOpt(_this.items[i].getAttribute('dataValue'),"add"); <br /> } <br /> //加点单击事件 <br /> _this.items[i].onclick=function(){ <br /> //是否为单选 <br /> var radio = _this.config.Raido?_this.config.Raido:true; <br /> if(_this.config.Radio==null || _this.config.Radio){ <br /> if(this.className!=_this.selectClass){ <br /> var items = this.parentNode.getElementsByTagName("li"); <br /> for(var i=0;i<items.length;i ){ <br /> items[i].className=""; <br /> } <br /> _this.selected.length = 0; <br /> _this.selected.push(this.getAttribute('dataValue')); <br /> this.className=_this.selectClass; <br /> } <br /> }else{ <br /> var Max = _this.config.Max?_this.config.Max:1; <br /> if(this.className==_this.selectClass){ <br /> this.className=""; <br /> _this.selectOpt(this.getAttribute('dataValue'),"remove"); <br /> }else{ <br /> if(_this.selected.length>=Max){ <br /> alert("最多只能选择" Max "项"); <br /> }else{ <br /> this.className=_this.selectClass; <br /> _this.selectOpt(this.getAttribute('dataValue'),"add"); <br /> } <br /> } <br /> } <br /> //去掉那个虚线框 <br /> this.firstChild.blur(); <br /> //调用回调函数 <br /> if(_this.config.OnClick)_this.config.OnClick.call(this,_this.selected); <br /> return false; <br /> } <br /> } <br /> })(_this); <br /> } <br /> </script>
The poster said: Do the effects of a:hover overlap?
<html><head><meta http-equiv="Content-Language" content="zh-cn"><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><script type="text/javascript" src="http://www.heredc.com/js/jquery-ui-1.8.18.custom.min.js"></script><script type="text/javascript" src="http://www.heredc.com/js/jquery.min.js"></script><!--这里是内容B的--><script type="text/javascript"> function selectTag(showContent,selfObj){var tag = document.getElementById("tags").getElementsByTagName("li");var taglength = tag.length;for(i=0; i<taglength; i++){tag[i].className = "";}selfObj.parentNode.className = "selectTag";for(i=0; j=document.getElementById("tagContent"+i); i++){j.style.display = "none";}document.getElementById(showContent).style.display = "block";}</script><style type="text/css">ul,dl,dd,h1,h2,h3,h4,h5,h6,form,p,input,li{ padding:0; margin:0;}ul,li{list-style-type:none;}img { border:0;}.clear{clear:both;line-height:1px;}#con { margin:20px auto;}#tags {width: 750px; height: 27px;position:relative;bottom:-3px;}/* 切换风格start*/#tags LI {background: url(http://www.heredc.com/js/tab/tab_bg_left_02.gif) no-repeat left bottom; float: left; margin-right: 1px; margin-right: 6px;list-style:none; height: 24px}#tags LI A {padding:0 20px 0 20px;background: url(http://www.heredc.com/js/tab/tab_right_02.gif) no-repeat right bottom; float: left;color: #000; line-height: 24px;height: 24px; text-decoration: none;}/* 切换风格end*/#tags LI.emptyTag {background: none transparent scroll repeat 0% 0%; width: 4px;}#tags LI.selectTag {background-position: left top; margin-bottom: -2px; position: relative;top:-2px; height: 27px;}#tags LI.selectTag A {padding:0 20px 0 20px;background-position: right top; font-size:14px;color: #fff;font-weight:bold; line-height: 25px; height: 27px;}#tags LI A p{position:relative;top:2px;}#tagContent {border-top: #fa4e86 2px solid;}/*粉色02*/.tagContent { display: none;}#tagContent DIV.selectTag {display: block;}</style><!--这里是内容A的--><script type="text/javascript">window.onload=function(){ var size = new Select("size",{ Radio :true , OnClick:function(selected){ document.form.size.value = selected.join(",") document.form.color.value='';}});}</script><style type="text/css">ul{list-style-type:none;}ul li{float:left;display:inline;margin-right:5px;width:auto;overflow:hidden;}ul li a{display:block;border:1px solid #CCCCCC;padding:5px 6px 5px 6px;margin:1px;}.test a:hover{border:2px solid #FF6701;margin:0px;}.select{}.select a{border:2px solid #FF6701;margin:0px;background:url(http://www.heredc.com/js/2010083011191628.gif) no-repeat no-repeat right bottom;}</style><!--这个JS是内容B的--><script type="text/javascript">$(function() {$('#tabs').tabs();});</script> </head><body><table border="0" cellpadding="0" cellspacing="0" width="100%" id="table22"><tr><td><!--内容A--><ul id="size" class="test"><li dataValue="1"><a href="javascript:void(0)" onclick="Rchange(1,'myys')">S</a></li><li dataValue="2"><a href="javascript:void(0)" onclick="Rchange(2,'myys')">X</a></li><li dataValue="3"><a href="javascript:void(0)" onclick="Rchange(3,'myys')">XL</a></li></ul><br><br><!--内容B--><DIV id="con"><UL id="tags"> <LI class="selectTag"><A onClick="selectTag('tagContent0',this)" onFocus="this.blur()" href="javascript:void(0)"><p>商品介绍</p></A></LI><LI><A onClick="selectTag('tagContent1',this)" onFocus="this.blur()" href="javascript:void(0)"><p>评价详情(<font color="#0066FF">0</font>)</p></A></LI><LI><A onClick="selectTag('tagContent2',this)" onFocus="this.blur()" href="javascript:void(0)"><p>成交记录(<font color="#0066FF">50</font>)</p></A></LI></UL><DIV id="tagContent"> <DIV class="tagContent selectTag" id="tagContent0">001</DIV><DIV class="tagContent " id="tagContent1">002</DIV><DIV class="tagContent " id="tagContent2">003</DIV></DIV></DIV> </td></tr></table></body></html><!--这个JS是内容A的--><script language="javascript" type="text/javascript">function Select(id,config){ this.config = config||{}; this.id = typeof(id)=='string'?document.getElementById(id):id; this.items = this.id.getElementsByTagName("li"); this.selectClass = "select"; this.selected = new Array(); var _this = this; this.selectOpt = function(value,opt){ var exist = false; for(var i=0;i<_this.selected.length;i++){ if(_this.selected[i]==value){ exist = true ; if(opt=="remove"){ _this.selected.splice(i,1);} break; } } if(!exist && opt=="add"){_this.selected.push(value);} }; //初始化对象 (function(_this){ //是否有默认配置的选择项 if(_this.config.Default){ var arr = _this.config.Default.split(","); for(var i=0;i<arr.length;i++)_this.selectOpt(arr[i],"add"); } for(var i=0;i<_this.items.length;i++){ //将defalut中配置的项加上样式 if( _this.selected.join(",").indexOf(_this.items[i].getAttribute('dataValue'))>-1 && _this.items[i].className==""){ _this.items[i].className=_this.selectClass; } //如果有样式中定义了默认 if(_this.items[i].className==_this.selectClass){ _this.selectOpt(_this.items[i].getAttribute('dataValue'),"add"); } //加点单击事件 _this.items[i].onclick=function(){ //是否为单选 var radio = _this.config.Raido?_this.config.Raido:true; if(_this.config.Radio==null || _this.config.Radio){ if(this.className!=_this.selectClass){ var items = this.parentNode.getElementsByTagName("li"); for(var i=0;i<items.length;i++){ items[i].className=""; } _this.selected.length = 0; _this.selected.push(this.getAttribute('dataValue')); this.className=_this.selectClass; } }else{ var Max = _this.config.Max?_this.config.Max:1; if(this.className==_this.selectClass){ this.className=""; _this.selectOpt(this.getAttribute('dataValue'),"remove"); }else{ if(_this.selected.length>=Max){ alert("最多只能选择"+Max+"项"); }else{ this.className=_this.selectClass; _this.selectOpt(this.getAttribute('dataValue'),"add"); } } } //去掉那个虚线框 this.firstChild.blur(); //调用回调函数 if(_this.config.OnClick)_this.config.OnClick.call(this,_this.selected); return false; } } })(_this); }</script>
@calmcrime
That’s right. The styles of content A and content B overlap. What I want to achieve is: content A uses the style of content A, and content B uses the style of content B without interfering with each other. Thank you
Because the style of content A is more important, I hope you can help me modify the style of content B instead of modifying the style of A. Thank you
Does it mean the third floor?
Does it mean the third floor?
Hero, I left a message for you, please take a look, or add me QQ 77644278, it may be clearer to take a screenshot in QQ for you, thank you!
@calmcrime
Hero, or you can make the code into an HTML file and you can see what is going on.
If you have any questions, just ask here and post a screenshot
@calmcrime
Hero, let me give you a link to make it more intuitive
http: //www.heredc.com/js/a.htm
Re-specify style 2:
border:0px;
No?

HTMLtagsdefinethestructureofawebpage,whileattributesaddfunctionalityanddetails.1)Tagslike,,andoutlinethecontent'splacement.2)Attributessuchassrc,class,andstyleenhancetagsbyspecifyingimagesources,styling,andmore,improvingfunctionalityandappearance.

The future of HTML will develop in a more semantic, functional and modular direction. 1) Semanticization will make the tag describe the content more clearly, improving SEO and barrier-free access. 2) Functionalization will introduce new elements and attributes to meet user needs. 3) Modularity will support component development and improve code reusability.

HTMLattributesarecrucialinwebdevelopmentforcontrollingbehavior,appearance,andfunctionality.Theyenhanceinteractivity,accessibility,andSEO.Forexample,thesrcattributeintagsimpactsSEO,whileonclickintagsaddsinteractivity.Touseattributeseffectively:1)Usese

The alt attribute is an important part of the tag in HTML and is used to provide alternative text for images. 1. When the image cannot be loaded, the text in the alt attribute will be displayed to improve the user experience. 2. Screen readers use the alt attribute to help visually impaired users understand the content of the picture. 3. Search engines index text in the alt attribute to improve the SEO ranking of web pages.

The roles of HTML, CSS and JavaScript in web development are: 1. HTML is used to build web page structure; 2. CSS is used to beautify the appearance of web pages; 3. JavaScript is used to achieve dynamic interaction. Through tags, styles and scripts, these three together build the core functions of modern web pages.

Setting the lang attributes of a tag is a key step in optimizing web accessibility and SEO. 1) Set the lang attribute in the tag, such as. 2) In multilingual content, set lang attributes for different language parts, such as. 3) Use language codes that comply with ISO639-1 standards, such as "en", "fr", "zh", etc. Correctly setting the lang attribute can improve the accessibility of web pages and search engine rankings.

HTMLattributesareessentialforenhancingwebelements'functionalityandappearance.Theyaddinformationtodefinebehavior,appearance,andinteraction,makingwebsitesinteractive,responsive,andvisuallyappealing.Attributeslikesrc,href,class,type,anddisabledtransform

TocreatealistinHTML,useforunorderedlistsandfororderedlists:1)Forunorderedlists,wrapitemsinanduseforeachitem,renderingasabulletedlist.2)Fororderedlists,useandfornumberedlists,customizablewiththetypeattributefordifferentnumberingstyles.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Linux new version
SublimeText3 Linux latest version

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Notepad++7.3.1
Easy-to-use and free code editor
