CSS3實(shí)現(xiàn)左上角或右上角顯示提醒圓點(diǎn)的示例代碼
發(fā)布時(shí)間:2020-10-15 16:24:02 作者:技術(shù)leader
我要評(píng)論
這篇文章主要介紹了CSS3實(shí)現(xiàn)左上角或右上角顯示提醒圓點(diǎn),本文通過(guò)實(shí)例代碼給大家介紹了左上角實(shí)現(xiàn)紅色三角號(hào)標(biāo)識(shí)的代碼,對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
效果圖(如果想要三角形請(qǐng)點(diǎn)擊這里):

代碼:
<html>
<head>
<style type="text/css">
.message_s {
position: relative;
cursor: pointer;
}
.message_s:after {
position: absolute;
content: "";
/*以下內(nèi)容可以根據(jù)實(shí)際需要進(jìn)行調(diào)整 -----start------*/
top: 0px;
left: -13px; /*改成:right: -13px; 圓點(diǎn)顯示在右側(cè)*/
width: 8px;
height: 8px;
border-radius: 50%;
background-color: #e98b7f;
/*-----end------*/
}
div {
height: 30px;
border: 1px #000 solid;
width: 300px;
line-height: 30px;
padding: 0px 0px 0px 15px;
}
</style>
<script>
function clickAction()
{
console.log("天不生我leader,鍵道萬(wàn)古長(zhǎng)如夜!");
}
</script>
</head>
<body>
<div>
<span class="message_s" onclick="clickAction()"></span>
劍開(kāi)天門(mén)
</div>
</body>
</html>
附錄:下面看下左上角實(shí)現(xiàn)紅色三角號(hào)標(biāo)識(shí)
左上角實(shí)現(xiàn)紅色三角號(hào)標(biāo)識(shí),如圖

利用偽類(lèi)實(shí)現(xiàn),position和transform、border屬性為重點(diǎn)。
位置調(diào)整修改top和left的值即可。
<html>
<head>
<title> New Document </title>
<style>
div {
background-color: #f4f4f4;
padding: 20px;
}
.message_s {
position: relative;
}
.message_s:after {
position: absolute;
top: -25px;
display: block;
width: 0;
height: 0;
border: 16px solid transparent;
content: "";
-webkit-transform: rotate(45deg);
}
.message_s:after {
left: -25px;
z-index: 0;
border-right-color: red;
}
</style>
</head>
<body>
<div>
<span class="message_s">Internet Explorer 10、Firefox、Opera 支持 transform 屬性。Internet Explorer 9 支持替代的 -ms-transform 屬性(僅適用于 2D 轉(zhuǎn)換)。Safari 和 Chrome 支持替代的 -webkit-transform 屬性(3D 和 2D 轉(zhuǎn)換)。Opera 只支持 2D 轉(zhuǎn)換。</span>
</div>
</body>
</html>
到此這篇關(guān)于CSS3實(shí)現(xiàn)左上角或右上角顯示提醒圓點(diǎn)的示例代碼的文章就介紹到這了,更多相關(guān)css3提醒圓點(diǎn)內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持腳本之家!
相關(guān)文章
本文通過(guò)實(shí)例代碼給大家介紹了css右上角飄帶效果,代碼簡(jiǎn)單易懂,對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友參考下吧2022-03-18


