需要HTML工具提示

时间:2020-06-26 12:47:21

标签: javascript html jquery css

请为我的项目提供帮助,我的html中需要一个工具提示,我的问题是,如何在现有的图标或图片中添加工具提示?

对不起,我的英语不好,这是我的代码(HTML和CSS):

/*------------------------------------------------------------------
Project:  Celery
Version:  1.2
Last change:
Assigned to:
Primary use:
-------------------------------------------------------------------*/



/*//////////////////////////////////////////////////////////////////
[ FONT ]*/

@font-face {
  font-family: PlayfairDisplay-Regular;
  src: url('../fonts/PlayfairDisplay/PlayfairDisplay-Regular.ttf');
}

@font-face {
  font-family: PlayfairDisplay-BlackItalic;
  src: url('../fonts/PlayfairDisplay/PlayfairDisplay-BlackItalic.ttf');
}

@font-face {
  font-family: Poppins-Regular;
  src: url('../fonts/Poppins/Poppins-Regular.ttf');
}

@font-face {
  font-family: Poppins-Medium;
  src: url('../fonts/Poppins/Poppins-Medium.ttf');
}

/*//////////////////////////////////////////////////////////////////
[ RS PLUGIN ]*/
/*---------------------------------------------*/
.container {max-width: 1200px;}


/*//////////////////////////////////////////////////////////////////
[ Form ]*/
.contact100-form {
  max-width: 100%;
}
/*------------------------------------------------------------------
[ Input ]*/

.wrap-input100 {
  width: 650px;
  max-width: calc(100% + 110px);
  position: relative;
  background-color: transparent;
  height: 80px;
}

@media (max-width: 992px) {
  .wrap-input100 {
    max-width: 100%;
  }
}

/*---------------------------------------------*/
.input100 {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0 80px 0 172px;
  background-color: #ffe151;

  box-shadow: 0 10px 15px 0px rgba(0,0,0,0.1);
  -moz-box-shadow: 0 10px 15px 0px rgba(0,0,0,0.1);
  -webkit-box-shadow: 0 10px 15px 0px rgba(0,0,0,0.1);
  -o-box-shadow: 0 10px 15px 0px rgba(0,0,0,0.1);
  -ms-box-shadow: 0 10px 15px 0px rgba(0,0,0,0.1);
}

.input100:focus {
  box-shadow: 0 10px 15px 0px rgba(0,0,0,0.2);
  -moz-box-shadow: 0 10px 15px 0px rgba(0,0,0,0.2);
  -webkit-box-shadow: 0 10px 15px 0px rgba(0,0,0,0.2);
  -o-box-shadow: 0 10px 15px 0px rgba(0,0,0,0.2);
  -ms-box-shadow: 0 10px 15px 0px rgba(0,0,0,0.2);
}

@media (max-width: 576px) {
  .input100 {
    padding-left: 25px;
    padding-right: 60px;
  }
}


/*------------------------------------------------------------------
[ Alert validate ]*/

.validate-input {
  position: relative;
}

.alert-validate::before {
  content: attr(data-validate);
  position: absolute;
  max-width: 70%;
  background-color: #fff;
  border: 1px solid #c80000;
  border-radius: 0px;
  padding: 4px 25px 4px 10px;
  top: 50%;
  -webkit-transform: translateY(-50%);
  -moz-transform: translateY(-50%);
  -ms-transform: translateY(-50%);
  -o-transform: translateY(-50%);
  transform: translateY(-50%);
  right: 72px;
  pointer-events: none;

  font-family: Poppins-Medium;
  color: #c80000;
  font-size: 14px;
  line-height: 1.4;
  text-align: left;

  visibility: hidden;
  opacity: 0;

  -webkit-transition: opacity 0.4s;
  -o-transition: opacity 0.4s;
  -moz-transition: opacity 0.4s;
  transition: opacity 0.4s;
}

.alert-validate::after {
  content: "\f071";
  font-family: FontAwesome;
  display: block;
  position: absolute;
  color: #c80000;
  font-size: 14px;
  top: 50%;
  -webkit-transform: translateY(-50%);
  -moz-transform: translateY(-50%);
  -ms-transform: translateY(-50%);
  -o-transform: translateY(-50%);
  transform: translateY(-50%);
  right: 78px;
}

.alert-validate:hover:before {
  visibility: visible;
  opacity: 1;
}

@media (max-width: 992px) {
  .alert-validate::before {
    visibility: visible;
    opacity: 1;
  }
}


/*//////////////////////////////////////////////////////////////////
[ Simple slide100 ]*/
.simpleslide100-parent {
  position: relative;
  z-index: 1;
}

.simpleslide100 {
  display: block;
  position: absolute;
  z-index: -1;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
}

.simpleslide100-item {
  display: block;
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
}



/*==================================================================
    TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT
==================================================================*/

/*==================================================================
[ Color ]*/
.cl0 {color: #fff;}
.cl1 {color: #333;}




/*//////////////////////////////////////////////////////////////////
[ S-Text 0 - 15 ]*/

/*---------------------------------------------*/
.s2-txt1 {
  font-family: Poppins-Medium;
  font-size: 15px;
  color: #333;
  line-height: 1.2;
}



/*//////////////////////////////////////////////////////////////////
[ M-Text 16 - 25 ]*/

/*---------------------------------------------*/
.m2-txt1 {
  font-family: Poppins-Regular;
  font-size: 24px;
  color: #999;
  line-height: 1.2;
}

.m2-txt2 {
  font-family: Poppins-Regular;
  font-size: 16px;
  color: #999;
  line-height: 1.2;
  text-transform: uppercase;
}



/*//////////////////////////////////////////////////////////////////
[ L-Text >= 26 ]*/
.l1-txt1 {
  font-family: PlayfairDisplay-Regular;
  font-size: 60px;
  color: #333;
  line-height: 1.1;
  text-transform: uppercase;
}


/*==================================================================
   SHAPE SHAPE SHAPE SHAPE SHAPE SHAPE SHAPE SHAPE SHAPE SHAPE SHAPE
==================================================================*/
/*//////////////////////////////////////////////////////////////////
[ Size ]*/
.size1 {
  width: 100%;
  min-height: 100vh;
}

.size2 {
  width: 80px;
  height: 80px;
}

.size3 {
  width: 36px;
  height: 36px;
}

.size4 {
  width: 172px;
  height: 80px;
}

/*//////////////////////////////////////////////////////////////////
[ Width ]*/
.wsize1 {
  width: 37%;
}

.wsize2 {
  width: 63%;
}

.wsize3 {
  max-width: 100%;
}

/*//////////////////////////////////////////////////////////////////
[ Height ]*/




/*//////////////////////////////////////////////////////////////////
[ Background ]*/
.bg0 {background-color: #fff;}

.bg-img1 {
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
}




/*//////////////////////////////////////////////////////////////////
[ Border ]*/
.bor1 {
  border-left: 5px solid #333;
}




/*==================================================================
   WHERE WHERE WHERE WHERE WHERE WHERE WHERE WHERE WHERE WHERE WHERE
==================================================================*/




/*==================================================================
 HOW HOW HOW HOW HOW HOW HOW HOW HOW HOW HOW HOW HOW HOW HOW HOW HOW
==================================================================*/
.placeholder0::-webkit-input-placeholder { color: #666;}
.placeholder0:-moz-placeholder { color: #666;}
.placeholder0::-moz-placeholder { color: #666;}
.placeholder0:-ms-input-placeholder { color: #666;}


/*---------------------------------------------*/
.overlay1 {
  position: relative;
  z-index: 1;
}
.overlay1::after {
  content: "";
  display: block;
  position: absolute;
  z-index: -1;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  background: rgba(0,0,0,0.5);
}

/*---------------------------------------------*/
.wrappic1 {
  display: block;
}

.wrappic1 img {
  max-width: 100%;
}

/*---------------------------------------------*/
.how-btn1 {
  padding: 0 15px;
  background-color: #fff;
  border-radius: 25px;
}

.how-btn1:hover {
  background-color: #555555;
  color: #fff;
}

/*---------------------------------------------*/
.how-social {
  color: #666;
  font-size: 16px;
  background-color: transparent;
  border-radius: 50%;
  border: 1px solid #e6e6e6;
}

.how-social:hover {
  background-color: #333;
  color: #fff;
}


/*//////////////////////////////////////////////////////////////////
[ Pseudo ]*/

/*------------------------------------------------------------------
[ Focus ]*/
.focus-in0:focus::-webkit-input-placeholder { color:transparent; }
.focus-in0:focus:-moz-placeholder { color:transparent; }
.focus-in0:focus::-moz-placeholder { color:transparent; }
.focus-in0:focus:-ms-input-placeholder { color:transparent; }


/*------------------------------------------------------------------
[ Hover ]*/
.hov-cl0:hover {color: #fff;}
.hov-bg0:hover {background-color: #fff;}

/*---------------------------------------------*/
.hov1:hover i {
  -webkit-transform: translateX(10px);
  -moz-transform: translateX(10px);
  -ms-transform: translateX(10px);
  -o-transform: translateX(10px);
  transform: translateX(10px);
}






/*==================================================================
  RESPONSIVE RESPONSIVE RESPONSIVE RESPONSIVE RESPONSIVE RESPONSIVE
==================================================================*/


/*//////////////////////////////////////////////////////////////////
[ XL ]*/
@media (max-width: 1200px) {
  .m-0-xl {margin: 0;}
  .m-lr-0-xl {margin-left: 0; margin-right: 0;}
  .m-lr-15-xl {margin-left: 15px; margin-right: 15px;}
  .m-l-0-xl {margin-left: 0;}
  .m-r-0-xl {margin-right: 0;}
  .m-l-15-xl {margin-left: 15px;}
  .m-r-15-xl {margin-right: 15px;}

  .p-0-xl {padding: 0;}
  .p-lr-0-xl {padding-left: 0; padding-right: 0;}
  .p-lr-15-xl {padding-left: 15px; padding-right: 15px;}
  .p-l-0-xl {padding-left: 0;}
  .p-r-0-xl {padding-right: 0;}
  .p-l-15-xl {padding-left: 15px;}
  .p-r-15-xl {padding-right: 15px;}

  .w-full-xl {width: 100%;}

  /*---------------------------------------------*/
  .respon1 {
    width: 60%;
  }

  /*---------------------------------------------*/
  .respon2 {
    width: 40%;
  }

}


/*//////////////////////////////////////////////////////////////////
[ LG ]*/
@media (max-width: 992px) {
  .dis-none-lg {display: none;}
  .m-0-lg {margin: 0;}
  .m-lr-0-lg {margin-left: 0; margin-right: 0;}
  .m-lr-15-lg {margin-left: 15px; margin-right: 15px;}
  .m-l-0-lg {margin-left: 0;}
  .m-r-0-lg {margin-right: 0;}
  .m-l-15-lg {margin-left: 15px;}
  .m-r-15-lg {margin-right: 15px;}

  .p-0-lg {padding: 0;}
  .p-lr-0-lg {padding-left: 0; padding-right: 0;}
  .p-lr-15-lg {padding-left: 15px; padding-right: 15px;}
  .p-l-0-lg {padding-left: 0;}
  .p-r-0-lg{padding-right: 0;}
  .p-l-15-lg {padding-left: 15px;}
  .p-r-15-lg {padding-right: 15px;}

  .w-full-lg {width: 100%;}

  /*---------------------------------------------*/
  .respon1 {
    width: 100%;
    padding-left: 15px;
    padding-right: 15px;
  }

  /*---------------------------------------------*/
  .respon2 {
    width: 100%;
    height: 500px;
  }


}


/*//////////////////////////////////////////////////////////////////
[ MD ]*/
@media (max-width: 768px) {
  .m-0-md {margin: 0;}
  .m-lr-0-md {margin-left: 0; margin-right: 0;}
  .m-lr-15-md {margin-left: 15px; margin-right: 15px;}
  .m-l-0-md {margin-left: 0;}
  .m-r-0-md {margin-right: 0;}
  .m-l-15-md {margin-left: 15px;}
  .m-r-15-md {margin-right: 15px;}

  .p-0-md {padding: 0;}
  .p-lr-0-md {padding-left: 0; padding-right: 0;}
  .p-lr-15-md {padding-left: 15px; padding-right: 15px;}
  .p-l-0-md {padding-left: 0;}
  .p-r-0-md{padding-right: 0;}
  .p-l-15-md {padding-left: 15px;}
  .p-r-15-md {padding-right: 15px;}

  .w-full-md {width: 100%;}
  /*---------------------------------------------*/

}


/*//////////////////////////////////////////////////////////////////
[ SM ]*/
@media (max-width: 576px) {
  .dis-none-sm {display: none;}
  .m-0-sm {margin: 0;}
  .m-lr-0-sm {margin-left: 0; margin-right: 0;}
  .m-lr-15-sm {margin-left: 15px; margin-right: 15px;}
  .m-l-0-sm {margin-left: 0;}
  .m-r-0-sm {margin-right: 0;}
  .m-l-15-sm {margin-left: 15px;}
  .m-r-15-sm {margin-right: 15px;}

  .p-0-sm {padding: 0;}
  .p-lr-0-sm {padding-left: 0; padding-right: 0;}
  .p-lr-15-sm {padding-left: 15px; padding-right: 15px;}
  .p-l-0-sm {padding-left: 0;}
  .p-r-0-sm{padding-right: 0;}
  .p-l-15-sm {padding-left: 15px;}
  .p-r-15-sm {padding-right: 15px;}

  .w-full-sm {width: 100%;}

  /*---------------------------------------------*/
  .respon3 {
    font-size: 60px;
  }

  /*---------------------------------------------*/
  .respon4 {
    width: 5px;
  }

  .respon4 span {
    display: none;
  }

  /*---------------------------------------------*/
  .respon5 {
    width: 60px;
  }

}


/*//////////////////////////////////////////////////////////////////
[ SSM ]*/
@media (max-width: 480px) {
  .m-0-ssm {margin: 0;}
  .m-lr-0-ssm {margin-left: 0; margin-right: 0;}
  .m-lr-15-ssm {margin-left: 15px; margin-right: 15px;}
  .m-l-0-ssm {margin-left: 0;}
  .m-r-0-ssm {margin-right: 0;}
  .m-l-15-ssm {margin-left: 15px;}
  .m-r-15-ssm {margin-right: 15px;}

  .p-0-ssm {padding: 0;}
  .p-lr-0-ssm {padding-left: 0; padding-right: 0;}
  .p-lr-15-ssm {padding-left: 15px; padding-right: 15px;}
  .p-l-0-ssm {padding-left: 0;}
  .p-r-0-ssm{padding-right: 0;}
  .p-l-15-ssm {padding-left: 15px;}
  .p-r-15-ssm {padding-right: 15px;}

  .w-full-ssm {width: 100%;}
  /*---------------------------------------------*/

}
<!DOCTYPE html>
<html lang="en">
<head>
    <title>AN Newsletter | Thank you</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
<!--===============================================================================================-->
    <link rel="icon" type="image/png" href="images/icons/favicon.ico"/>
<!--===============================================================================================-->
    <link rel="stylesheet" type="text/css" href="vendor/bootstrap/css/bootstrap.min.css">
<!--===============================================================================================-->
    <link rel="stylesheet" type="text/css" href="fonts/font-awesome-4.7.0/css/font-awesome.min.css">
<!--===============================================================================================-->
    <link rel="stylesheet" type="text/css" href="fonts/iconic/css/material-design-iconic-font.min.css">
<!--===============================================================================================-->
    <link rel="stylesheet" type="text/css" href="vendor/animate/animate.css">
<!--===============================================================================================-->
    <link rel="stylesheet" type="text/css" href="vendor/select2/select2.min.css">
<!--===============================================================================================-->
    <link rel="stylesheet" type="text/css" href="css/util.css">
    <link rel="stylesheet" type="text/css" href="css/main.css">
<!--===============================================================================================-->
</head>
<body>



    <div class="flex-w flex-str size1 overlay1">
        <div class="flex-w flex-col-sb wsize1 bg0 p-l-70 p-t-37 p-b-52 p-r-50 respon1">
            <div class="wrappic1">
                <a href="../main/index.html">
                    <img src="images/icons/logo.png" alt="IMG">
                </a>
            </div>

            <div class="w-full p-t-100 p-b-90 p-l-48 p-l-0-md">

                <h3 class="l1-txt1 p-b-34 respon3">
                    Thank you
                </h3>

                <p class="m2-txt1 p-b-46">
                    Your request has been received.
                </p>

            </div>

            <div class="flex-w flex-m">
                <span class="m2-txt2 p-r-40">
                    Navigation
                </span>

                <a href="../main/index.html" class="size3 flex-c-m how-social trans-04 m-r-15 m-b-5 m-t-5">
                    <i class="fa fa-home"></i>
                </a>

                <a href="../main/contact.html" class="size3 flex-c-m how-social trans-04 m-r-15 m-b-5 m-t-5">
                    <i class="fa fa-phone"></i>
                </a>

                <a href="#" class="size3 flex-c-m how-social trans-04 m-r-15 m-b-5 m-t-5">
                    <i class="fa fa-question"></i>
                </a>

                <a href="#" class="size3 flex-c-m how-social trans-04 m-r-15 m-b-5 m-t-5">
                    <i class="fa fa-comment"></i>
                </a>

            </div>
        </div>


        <div class="wsize2 bg-img1 respon2" style="background-image: url('images/bg01.jpg');">
        </div>
    </div>





<!--===============================================================================================-->
    <script src="vendor/jquery/jquery-3.2.1.min.js"></script>
<!--===============================================================================================-->
    <script src="vendor/bootstrap/js/popper.js"></script>
    <script src="vendor/bootstrap/js/bootstrap.min.js"></script>
<!--===============================================================================================-->
    <script src="vendor/select2/select2.min.js"></script>
<!--===============================================================================================-->
    <script src="vendor/tilt/tilt.jquery.min.js"></script>
<!--===============================================================================================-->
    <script src="js/main.js"></script>

</body>
</html>

请通过添加工具提示语法来帮助我,我们将不胜感激

该工具提示适用于HTML的这一部分:

            <div class="flex-w flex-m">
                <span class="m2-txt2 p-r-40">
                    Navigation
                </span>

                <a href="../main/index.html" class="size3 flex-c-m how-social trans-04 m-r-15 m-b-5 m-t-5">
                    <i class="fa fa-home"></i>
                </a>

                <a href="../main/contact.html" class="size3 flex-c-m how-social trans-04 m-r-15 m-b-5 m-t-5">
                    <i class="fa fa-phone"></i>
                </a>

                <a href="#" class="size3 flex-c-m how-social trans-04 m-r-15 m-b-5 m-t-5">
                    <i class="fa fa-question"></i>
                </a>

                <a href="#" class="size3 flex-c-m how-social trans-04 m-r-15 m-b-5 m-t-5">
                    <i class="fa fa-comment"></i>
                </a>

            </div>

3 个答案:

答案 0 :(得分:1)

您可以使用<input type="file">作为工具提示消息。

如果您想使用简单的工具提示消息,则无需执行此CSS或任何操作。

当您将鼠标悬停在导航上时,它将显示“我是工具提示”。

几乎所有HTML元素都可以执行此操作。只需添加您自己的消息,以便用户将鼠标悬停在其上即可看到该消息。

您也可以使用title

在以下网址进一步了解自定义CSS工具提示https://www.w3schools.com/css/css_tooltip.asp

运行下面的代码片段以查看其工作情况。

img

答案 1 :(得分:0)

您正在寻找HTML属性title

答案 2 :(得分:0)

下次,请尝试提供与托管在codepen / jsfiddle上的代码的链接,以使阅读更简洁,更准确。从您的问题中我了解到的是,您希望为图片/内容提供一个悬停的文本选项。如果我不明白,请纠正我。这样的一种方法是:

<!DOCTYPE html>
<html>
<style>
.tooltip {
  position: relative;
  display: inline-block;
  border-bottom: 1px dotted black;
}

.tooltip .tooltiptext {
  visibility: hidden;
  width: 120px;
  background-color: black;
  color: #fff;
  text-align: center;
  border-radius: 6px;
  padding: 5px 0;

  /* Position the tooltip */
  position: absolute;
  z-index: 1;
}

.tooltip:hover .tooltiptext {
  visibility: visible;
}
</style>
<body>
<div class="tooltip">Hover over me
  <span class="tooltiptext">Tooltip text</span>
</div>
<br>
<br>
  <img src= "https://images.unsplash.com/photo-1494253109108-2e30c049369b?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&w=1000&q=80" title="example for hover tooltip" alt="simple image" width="300">

</body>
</html>

相关问题