HTML, CSS, and JS Primitives write a modal popup, which, by the way, resolves the parent element translucent sub-element opacity effect

Source: Internet
Author: User

Modal Frame:

HTML section:

<!--Button -    <ButtonID= "box"onclick= "Pop_box ()">Pop-up box</Button>    <!--pop-up modal box -    <Divclass= "Div-container"ID= "Div-container"style= "Display:none;">        <Divclass= "Div-child-container">            <Divclass= "Div-child">                <span>Hhhhh</span>                <Divclass= "My-btn">                    <ButtonID= "Canclebtn"onclick= "cancle ()">Cancel</Button>                    <ButtonID= "Confrim"onclick= "Confrim ()">Confirm</Button>                </Div>            </Div>        </Div>    </Div>

CSS section:

<style type= "Text/css" > #box{width:80px;Height:40px;background:#fd7430;Border:None;Border-radius:5px;Outline:None;Color:#fff; }. Div-container{position:fixed;Top:0%;width:100%;Height:100%;Z-index: $;background:Rgba (0,0,0,0.5)!important;/*compatible with IE several do not know, like IE5*/background:#000;Filter:Alpha (opacity=60); }/*the parent element of the set Div-child is primarily to inherit the transparency attribute of the parent element of this element, so the div-child is not translucent, but opaque, resolving the bug that the parent element is transparent and the child element is transparent.*/. Div-child-container{position:relative;width:400px;Height:200px;margin:Auto;Top:30%;background:#fff;Z-index: -;/*Z-index to be placed above the parent element*/}. Div-child{width:400px;Height:200px;margin:Auto;background:#fff;Z-index: -;/*Z-index to be placed above the parent element*/text-align:Center; }. Div-child span{position:relative;Top:40px; }. Div-child. my-btn{Margin-top:80px; }. Div-child. my-btn button{width:80px;Height:40px;background:#fd7430;Border:None;Border-radius:5px;Color:#fff;Outline:None; }. Div-child. My-btn button:first-child (){Margin-right:20px; }</style>

Javascript:

<script type= "Text/javascript" >/*button pop-up modal box*/        functionPop_box () {varcontainer = document.getElementById (' Div-container ')); Container.style.display= "Block"; }        /*Cancel Event*/        functioncancle () {varcontainer = document.getElementById (' Div-container ')); Container.style.display= "None"; }        /*confirm the event, because there is no confirmation event now, the popup box is hidden*/        functionConfrim () {varcontainer = document.getElementById (' Div-container ')); Container.style.display= "None"; }    </script>

HTML, CSS, and JS Primitives write a modal popup, which, by the way, resolves the parent element translucent sub-element opacity effect

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.