要为移动视图自定义工具提示

问题描述 投票:0回答:1

我已经为所有方向弹出式窗口创建了工具提示代码,但我只想在移动设备的顶部弹出式窗口,请帮助我。我无法编码@media屏幕代码,请任何人帮助我。编写用于(tooltip.top)唯一弹出窗口的移动设备的代码

 .tooltip {
    display:inline-block;
    position:relative;
    border-bottom:2px solid #ff5733;
    text-align:left;
}

.tooltip .right {
    min-width:200px; 
    top:50%;
    left:100%;
    margin-left:20px;
    transform:translate(0, -50%);
    padding:10px 20px;
    color:#444444;
    background-color:#EEEEEE;
    font-weight:normal;
    font-size:13px;
    border-radius:8px;
    position:absolute;
    z-index:99999999;
    box-sizing:border-box;
    box-shadow:0 1px 8px rgba(0,0,0,0.5);
    visibility:hidden; opacity:0; transition:opacity 0.8s;
}

.tooltip:hover .right {
    visibility:visible; opacity:1;
}

.tooltip .right i {
    position:absolute;
    top:50%;
    right:100%;
    margin-top:-12px;
    width:12px;
    height:24px;
    overflow:hidden;
}

.tooltip .right i::after {
    content:'';
    position:absolute;
    width:12px;
    height:12px;
    left:0;
    top:50%;
    transform:translate(50%,-50%) rotate(-45deg);
    background-color:#EEEEEE;
    box-shadow:0 1px 8px rgba(0,0,0,0.5);
}

.tooltip .top {
    min-width:200px; 
    top:-20px;
    left:50%;
    transform:translate(-50%, -100%);
    padding:10px 20px;
    color:#444444;
    background-color:#EEEEEE;
    font-weight:normal;
    font-size:13px;
    border-radius:8px;
    position:absolute;
    z-index:99999999;
    box-sizing:border-box;
    box-shadow:0 1px 8px rgba(0,0,0,0.5);
    visibility:hidden; opacity:0; transition:opacity 0.8s;
}

.tooltip:hover .top {
    visibility:visible; opacity:1;
}

.tooltip .top i {
    position:absolute;
    top:100%;
    left:50%;
    margin-left:-12px;
    width:24px;
    height:12px;
    overflow:hidden;
}

.tooltip .top i::after {
    content:'';
    position:absolute;
    width:12px;
    height:12px;
    left:50%;
    transform:translate(-50%,-50%) rotate(45deg);
    background-color:#EEEEEE;
    box-shadow:0 1px 8px rgba(0,0,0,0.5);
}
.tooltip .bottom {
    min-width:200px; 
    top:40px;
    left:50%;
    transform:translate(-50%, 0);
    padding:10px 20px;
    color:#444444;
    background-color:#EEEEEE;
    font-weight:normal;
    font-size:13px;
    border-radius:8px;
    position:absolute;
    z-index:99999999;
    box-sizing:border-box;
    box-shadow:0 1px 8px rgba(0,0,0,0.5);
    visibility:hidden; opacity:0; transition:opacity 0.8s;
}

.tooltip:hover .bottom {
    visibility:visible; opacity:1;
}

.tooltip .bottom i {
    position:absolute;
    bottom:100%;
    left:50%;
    margin-left:-12px;
    width:24px;
    height:12px;
    overflow:hidden;
}

.tooltip .bottom i::after {
    content:'';
    position:absolute;
    width:12px;
    height:12px;
    left:50%;
    transform:translate(-50%,50%) rotate(45deg);
    background-color:#EEEEEE;
    box-shadow:0 1px 8px rgba(0,0,0,0.5);
}

.tooltip .left {
    min-width:200px; 
    top:50%;
    right:100%;
    margin-right:20px;
    transform:translate(0, -50%);
    padding:10px 20px;
    color:#444444;
    background-color:#EEEEEE;
    font-weight:normal;
    font-size:13px;
    border-radius:8px;
    position:absolute;
    z-index:99999999;
    box-sizing:border-box;
    border:3px solid #ff5733;box-shadow:0 1px 8px rgba(0,0,0,0.5);
    visibility:hidden; opacity:0; transition:opacity 0.8s;
}

.tooltip:hover .left {
    visibility:visible; opacity:1;
}

.tooltip .left i {
    position:absolute;
    top:50%;
    left:100%;
    margin-top:-12px;
    width:12px;
    height:24px;
    overflow:hidden;
}

.tooltip .left i::after {
    content:'';
    position:absolute;
    width:12px;
    height:12px;
    left:0;
    top:50%;
    transform:translate(-50%,-50%) rotate(-45deg);
    background-color:#EEEEEE;
    border:3px solid #ff5733;box-shadow:0 1px 8px rgba(0,0,0,0.5);
}
<span class="btn btn-primary tooltip">Hover Me to Preview
    <span class="bottom">
        <h3>Lorem Ipsum</h3>
        <p>Dolor sit amet, consectetur adipiscing elit.ofugugvufg
        efuwgefwgcvurwef
        wfierhfvierhvoerihvr</p>
        <i></i>
    </span>
</span>

<span class="btn btn-primary tooltip">Hover Me to Preview
    <span class="top">
        <h3>Lorem Ipsum</h3>
        <p>Dolor sit amet, consectetur adipiscing elit.</p>
        <i></i>
    </span>
</span>
<span class="btn btn-primary tooltip">Hover Me to Preview
    <span class="left">
        <h3>Lorem Ipsum</h3>
        <p>Dolor sit amet, consectetur adipiscing elit.</p>
        <i></i>
    </span>
</span>
<span class="btn btn-primary tooltip">Hover Me to Preview
    <div class="right">
        <h3>Lorem Ipsum</h3>
        
        <p><img alt="The Bangle Sellers Poem's Workbook Solution" border="0" data-original-height="427" data-original-width="760" src="https://newsroom.ibm.com/image/security%2Bthumbnail%2B400x400.png"> consectetur 
        efrnvlkfnv</p>
        <i></i>
    </div>
    </span>

所有方向的工具提示代码是代码

css blogs
1个回答
0
投票

您可以针对移动设备的特定CSS进行媒体查询,类似于:

@media (max-width: 768px) {
    //Add your css here for example
    .tooltip:hover .right {
        visibility:visible; opacity:1;
    }
 }
© www.soinside.com 2019 - 2024. All rights reserved.