Table of Contents
Reply to discussion (solution)
Home Web Front-end HTML Tutorial Looking for a simple div css example_html/css_WEB-ITnose

Looking for a simple div css example_html/css_WEB-ITnose

Jun 24, 2016 pm 12:23 PM

div css mouseover javascript css

I want to make a small div with a large div above the small div. The large div is as wide as the small div and has a height higher than the small div. When the mouse is placed on the small div, the large div is displayed and covers the small div. Either implementation using javascript or css will work. The effect is achieved.

Reply to discussion (solution)

<!DOCTYPE html><!DOCTYPE html><html>    <head>        <title></title>        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">        <style>            .xiao{                border: solid 1px ;                width: 100px;                height: 100px;            }            .xiao>.da{                background-color: #ccc;                width: 100%;                height: 200px;                display: none;                background-image: url(http://avatar.csdn.net/3/5/3/1_wangwang008.jpg);                background-size: 100% 100%;            }            .xiao:hover>.da{                display: block;            }        </style>    </head>    <body>        <div class="xiao">            <div class="da"></div>        </div>    </body></html>
Copy after login

Your avatar saved me a meal

<!DOCTYPE html><!DOCTYPE html><html>    <head>        <title></title>         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">         <style>              .xiao{                border: solid 1px ;                width: 100px;                height: 100px;            }              .xiao>.da{                background-color: #ccc;                width: 100%;                height: 200px;                display: none;                         background-size: 100% 100%;            }              .xiao:hover>.da{      display: block;       }          </style>      </head>       <body>           <div class="xiao">   fdsafaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa        		 <div class="da">fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff		 </div>        	 </div>    	 </body>	 </html>
Copy after login


The picture can be covered, but it cannot be covered if there is content inside. I want the big one to completely cover the small one, including the content and pictures inside the small one

<html xmlns="http://www.w3.org/1999/xhtml"><head>    <title></title>    <style type="text/css">        .toopTip        {            background-color:Yellow;            border-style:solid;            border-width:1px;            border-color:Red;        }    </style>   <script language="javascript" type="text/javascript">       /*            如果希望提示的div的左边界与上边界与显示的div重叠,那么需要删除文档头W3C标准            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"             "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">                   */       function initEvent() {           var divArray = document.getElementsByTagName("div");           for (var i = 0; i < divArray.length; i++) {               divArray[i].onmouseover = createDivDetailOne;               /*                 无法用原始的div绑定鼠标移走的事件,因为明细的div的宽度长度都要大于原始div,                 这样原始的div就被覆盖了,此时会自动触发onmouseout事件               */               //divArray[i].onmouseout = removeDivDetail;           }       }       function createDivDetailOne() {           //保证divDetail div的唯一性           var divDetail = document.getElementById("divDetail");           if(divDetail)           {               document.body.removeChild(divDetail);           }           divObj = document.createElement("div");           divObj.className = "toopTip";           divObj.setAttribute("id", "divDetail");           divObj.style.position = "absolute";           divObj.style.width = "200px";           divObj.style.height = "100px";           var triggerObj = window.event.srcElement;           divObj.style.top = triggerObj.offsetTop;           divObj.style.left = triggerObj.offsetLeft;           divObj.innerHTML = triggerObj.innerText;           document.body.appendChild(divObj);           //此时用于明细的div已经覆盖了原div,所以覆盖的div要进行事件的处理           document.getElementById("divDetail").onmouseout = function() {               divObj = this;               if (!divObj) {                   return;               }               document.body.removeChild(divObj);           };       }       function removeDivDetail() {           var divObj = document.getElementById("divDetail");           if (!divObj) {               return;           }           document.body.removeChild(divObj);       }       window.onload = initEvent;    </script></head><body>    <div id="divOne" style="background-color: Fuchsia; width: 100px; height: 100px;" >        Hello  Js  1! <img src="1.jpg" width="50px" height="50px"/><img src="1.jpg" width="50px" height="50px"/>    </div>    <div id="divTwo" style="background-color: Aqua; width: 100px; height: 100px">        Welcome to 2!<img src="1.jpg" width="50px" height="50px"/>    </div>    <div id="divThree" style="background-color: Gray; width: 100px; height: 100px">        THIS IS  3    </div></body></html>
Copy after login


This is the rendering I want

The first order has two products, 'Product 1' and 'Product 11'. Move the mouse to any cell from the product name to the total price. Display detailed product information for this order.

sinbas Your effect is quite good, but the content in the three divs is not covered! I used ASP to dynamically generate this form, so it's not easy to add things in it. I'll do more research.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>无标题文档</title><style type="text/css">#small{	width:600px;	height:150px;	margin:auto;	margin-top:30px;}#small td{	width:80px;	height:30px;	text-align:center;}#big{	width:340px;	height:80px;	position:absolute;	left:470px;	top:68px;	display:none;	background-color:#CCC;}#big td{	width:80px;	height:30px;	text-align:center;}</style><script language="javascript">function show(divId){	divId.style.display="block";	}function hide(divId){	divId.style.display="none";	}</script></head><body><div id="small"><table width="600" border="1">  <tr>    <td>订单号</td>    <td onmouseover="show(big);" onmouseout="hide(big);">商品名</td>    <td onmouseover="show(big);" onmouseout="hide(big);">数量</td>    <td onmouseover="show(big);" onmouseout="hide(big);">单价</td>    <td onmouseover="show(big);" onmouseout="hide(big);">总价</td>    <td>卖家</td>    <td>买家</td>  </tr>  <tr>    <td>123</td>    <td>abc</td>    <td>456</td>    <td>1.1</td>    <td>9.0</td>    <td>ABC</td>    <td>DEF</td>  </tr></table></div><div id="big"><table width="340" border="1">  <tr>    <td>abc</td>    <td>23</td>    <td>24</td>    <td>33344</td>  </tr>  <tr>    <td>cde</td>    <td>33</td>    <td>21</td>    <td>345</td>  </tr></table></div>	</body></html>
Copy after login

lin9118 Friend did not understand what I meant. What I meant was that the mouse was placed on the order, and then the content expanded, not that the mouse was placed on the title.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"><title>ToolTip</title></head><script language="javascript">function show(qusetion, answer, email, divfId,divid){	document.getElementById("td1").innerText="问题:" + qusetion;	document.getElementById("td2").innerText="答案:" + answer;	document.getElementById("td3").innerText="邮箱:" + email;	var divfather=document.getElementById(divfId);	var divSon=document.getElementById(divid);	var x=divfather.offsetLeft;	var y=divfather.offsetTop;		divSon.style.position='absolute';	divSon.style.left = x;	divSon.style.top = y;	divSon.style.display="block";}function Hide(divid){    var div1=document.getElementById(divid);	div1.style.display="none";}</script><style>.banbu1,.banbu1{    width:400px;   z-index:1;	background-color:#CCCCCC;	margin-top:0	}.wai{position:relative;width:400px}</style><body><div class="wai" id="div6"><div class="banbu1" id="d4" onmousemove="show('问题一','答案一','邮箱一','d4','div4');" onmouseout="Hide('div4');">Hi30mnnnn<div id="div4" style="display:none; position:absolute;border:1px solid #FF6666;z-index:2;"><table border="0" cellpadding="0" bgcolor="#000" width="400px" height="100px"><tr><td width="180px" style="color:white">信息<hr /></td></tr><tr><td id="td1" height="25px" style="color:White"></td></tr><tr><td id="td2" height="25px" style="color:White"></td></tr><tr><td id="td3" height="25px" style="color:White"></td></tr></table></div></div></div><div class="banbu1" id="d2" onmouseout="Hide();">Hi</div><div class="banbu1" id="d2" onmouseout="Hide();">Hi</div><div class="banbu1" id="d2" onmouseout="Hide();">Hi</div><div class="banbu1" id="d2" onmouseout="Hide();">Hi</div><div class="banbu1" id="d2" onmouseout="Hide();">Hi</div><div class="banbu1" id="d2" onmouseout="Hide();">Hi</div><div class="banbu1" id="d2" onmouseout="Hide();">Hi</div><div class="banbu1" id="d2" onmouseout="Hide();">Hi</div><div class="banbu1" id="d2" onmouseout="Hide();">Hi</div><div class="banbu1" id="d2" onmouseout="Hide();">Hi</div><div class="banbu1" id="d2" onmouseout="Hide();">Hi</div><div class="banbu1" id="d2" onmouseout="Hide();">Hi</div><div class="banbu1" id="d2" onmouseout="Hide();">Hi</div><div class="banbu1" id="d2" onmouseout="Hide();">Hi</div><div class="banbu1" id="d2" onmouseout="Hide();">Hi</div></body></html>
Copy after login

Finally got it, I simplified it

Posted, thank you all!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Difficulty in updating caching of official account web pages: How to avoid the old cache affecting the user experience after version update? Difficulty in updating caching of official account web pages: How to avoid the old cache affecting the user experience after version update? Mar 04, 2025 pm 12:32 PM

Difficulty in updating caching of official account web pages: How to avoid the old cache affecting the user experience after version update?

How do I use HTML5 form validation attributes to validate user input? How do I use HTML5 form validation attributes to validate user input? Mar 17, 2025 pm 12:27 PM

How do I use HTML5 form validation attributes to validate user input?

How to efficiently add stroke effects to PNG images on web pages? How to efficiently add stroke effects to PNG images on web pages? Mar 04, 2025 pm 02:39 PM

How to efficiently add stroke effects to PNG images on web pages?

What is the purpose of the <iframe> tag? What are the security considerations when using it? What is the purpose of the <iframe> tag? What are the security considerations when using it? Mar 20, 2025 pm 06:05 PM

What is the purpose of the <iframe> tag? What are the security considerations when using it?

What is the purpose of the <datalist> element? What is the purpose of the <datalist> element? Mar 21, 2025 pm 12:33 PM

What is the purpose of the <datalist> element?

What is the purpose of the <meter> element? What is the purpose of the <meter> element? Mar 21, 2025 pm 12:35 PM

What is the purpose of the <meter> element?

What are the best practices for cross-browser compatibility in HTML5? What are the best practices for cross-browser compatibility in HTML5? Mar 17, 2025 pm 12:20 PM

What are the best practices for cross-browser compatibility in HTML5?

What is the purpose of the <progress> element? What is the purpose of the <progress> element? Mar 21, 2025 pm 12:34 PM

What is the purpose of the <progress> element?

See all articles