Making a simple tooltip with only HTML and CSS

前端 未结 5 849
闹比i
闹比i 2021-02-06 12:14

I want my tooltip element (the ) to appear above everything on the page but still relative to its parent element (the

5条回答
  •  无人共我
    2021-02-06 13:05

    I found a method to make a very lightweight tooltip with no JS!

    HTML:

    Send reminders?
    this is the tooltip alshdgwh gahfguo 
    wfhg fghwoug wugw hgrwuog hwaur guoarwhg rwu
    
    

    CSS: (must be in this order)

    .ht:hover .tooltip {
        display:block;
    }
    
    .tooltip {
        display: none;
        color: red;
        margin-left: 28px; /* moves the tooltip to the right */
        margin-top: 15px; /* moves it down */
        position: absolute;
        z-index: 1000;
    }
    

    Totally awesome and props to this guy!

提交回复
热议问题