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>
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>
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標(biāo)準(zhǔn) <!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綁定鼠標(biāo)移走的事件,因?yàn)槊骷?xì)的div的寬度長度都要大于原始div, 這樣原始的div就被覆蓋了,此時會自動觸發(fā)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); //此時用于明細(xì)的div已經(jīng)覆蓋了原div,所以覆蓋的div要進(jìn)行事件的處理 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>
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>無標(biāo)題文檔</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);">數(shù)量</td> <td onmouseover="show(big);" onmouseout="hide(big);">單價(jià)</td> <td onmouseover="show(big);" onmouseout="hide(big);">總價(jià)</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>
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>
Finally got it, I simplified it
Posted, thank you all!

Hot AI Tools

Undress AI Tool
Undress images for free

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

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

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

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

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

The key to keep up with HTML standards and best practices is to do it intentionally rather than follow it blindly. First, follow the summary or update logs of official sources such as WHATWG and W3C, understand new tags (such as) and attributes, and use them as references to solve difficult problems; second, subscribe to trusted web development newsletters and blogs, spend 10-15 minutes a week to browse updates, focus on actual use cases rather than just collecting articles; second, use developer tools and linters such as HTMLHint to optimize the code structure through instant feedback; finally, interact with the developer community, share experiences and learn other people's practical skills, so as to continuously improve HTML skills.

The reason for using tags is to improve the semantic structure and accessibility of web pages, make it easier for screen readers and search engines to understand page content, and allow users to quickly jump to core content. Here are the key points: 1. Each page should contain only one element; 2. It should not include content that is repeated across pages (such as sidebars or footers); 3. It can be used in conjunction with ARIA properties to enhance accessibility. Usually located after and before, it is used to wrap unique page content, such as articles, forms or product details, and should be avoided in, or in; to improve accessibility, aria-labeledby or aria-label can be used to clearly identify parts.

To create a basic HTML document, you first need to understand its basic structure and write code in a standard format. 1. Use the declaration document type at the beginning; 2. Use the tag to wrap the entire content; 3. Include and two main parts in it, which are used to store metadata such as titles, style sheet links, etc., and include user-visible content such as titles, paragraphs, pictures and links; 4. Save the file in .html format and open the viewing effect in the browser; 5. Then you can gradually add more elements to enrich the page content. Follow these steps to quickly build a basic web page.

To reduce the size of HTML files, you need to clean up redundant code, compress content, and optimize structure. 1. Delete unused tags, comments and extra blanks to reduce volume; 2. Move inline CSS and JavaScript to external files and merge multiple scripts or style blocks; 3. Simplify label syntax without affecting parsing, such as omitting optional closed tags or using short attributes; 4. After cleaning, enable server-side compression technologies such as Gzip or Brotli to further reduce the transmission volume. These steps can significantly improve page loading performance without sacrificing functionality.

To create an HTML checkbox, use the type attribute to set the element of the checkbox. 1. The basic structure includes id, name and label tags to ensure that clicking text can switch options; 2. Multiple related check boxes should use the same name but different values, and wrap them with fieldset to improve accessibility; 3. Hide native controls when customizing styles and use CSS to design alternative elements while maintaining the complete functions; 4. Ensure availability, pair labels, support keyboard navigation, and avoid relying on only visual prompts. The above steps can help developers correctly implement checkbox components that have both functional and aesthetics.

HTMLhasevolvedsignificantlysinceitscreationtomeetthegrowingdemandsofwebdevelopersandusers.Initiallyasimplemarkuplanguageforsharingdocuments,ithasundergonemajorupdates,includingHTML2.0,whichintroducedforms;HTML3.x,whichaddedvisualenhancementsandlayout

It is a semantic tag used in HTML5 to define the bottom of the page or content block, usually including copyright information, contact information or navigation links; it can be placed at the bottom of the page or nested in, etc. tags as the end of the block; when using it, you should pay attention to avoid repeated abuse and irrelevant content.

ThetabindexattributecontrolshowelementsreceivefocusviatheTabkey,withthreemainvalues:tabindex="0"addsanelementtothenaturaltaborder,tabindex="-1"allowsprogrammaticfocusonly,andtabindex="n"(positivenumber)setsacustomtabbing
