php - 如何在工具提示中显示按钮

标签 php html css

我的元素中有一个工具提示。 我喜欢做的是将事件按钮添加到我的工具提示中。 问题是工具提示显示的是 HTML 标签不是按钮...

这是我的工作效果:-) enter image description here

下面是我的代码。

如果有人可以提供帮助,请提供帮助。谢谢。

/* Frame */

.frame {
  height: 150px;
  max-width: 1170px;
  /*line-height: 130px;*/
/*  overflow:visible !important;*/
}

.frame ul {
  list-style: none;
  margin: 0;
  padding: 0;
  height: 100%;
  font-size: 14px;

}

.frame ul li {
  float: left;
  width: 232px;
  height: 100%;
  margin: 0 2px 0 0;
  padding: 0;
  background: #f1f1f1;
  color: #00b5f6;
  text-align: center;
  cursor: default;
  display:flex;
}

.frame ul li:hover{
  color: #fff;
  background: #00b5f6;

  
}


/* setup tooltips */
.tooltip {
  position: relative;
  z-index:1;
}
li .tooltip{
	overflow:visible;
}
.tooltip:before,
.tooltip:after {
  position:absolute;
  display:inline-block;
  opacity: 0;
  pointer-events: none;
  width:225px;

}
.tooltip:after {
	border-right: 6px solid transparent;
	border-top: 6px solid #00b5f6; 
  border-left: 6px solid transparent;
  content: '';
  height: 0;
    top: -5px;
    left: 20px;
  width: 0;
  display:none;
  

}
.tooltip:before {
  background: #00b5f6;
  border-radius: 2px;
  color: #fff;
  content: attr(data-title);
  font-size: 12px;
  padding: 6px 10px;
  top: 0px;
  left: 0px;
  white-space: nowrap;
  height:118px;
  max-width:212px !important;
  display:block;
  word-wrap: break-word;
  text-align: left;
  white-space: pre-line;
}

/* expand */
.tooltip.expand:before {
  transform: scale3d(.2,.2,1);
  transition: all .2s ease-in-out 0.5s;
}
.tooltip.expand:after {
  transform: translate3d(0,6px,0);
  transition: all .2s ease-in-out 0.5s;
}
.tooltip.expand:hover:before,
.tooltip.expand:hover:after {
  opacity: 1;
  transform: scale3d(1,1,1);
}
.date_event{
	text-align:left; width:232px; position:absolute; padding: 5px 0 0 5px; font-style: italic; max-height:20px; z-index:-1;
}
.suwak{
	width:232px; height:150px; margin-left:auto; margin-right:auto; overflow-y:visible; overflow-x:hidden; border:solid 1px #000;
}
.title_event{
	font-size:16px; font-weight:bold; width:232px; height:130px; vertical-align: middle !important; display: table-cell !important; margin-left:auto; margin-right:auto;
}
	  <?php $tooltip = "Lorem ipsum dolor sit amet enim.";
	   $tooltip = $tooltip."<div class='btn_google'>google</div>"; ?>

<div class="suwak">
<div class="frame" id="basic">
  <li class="tooltip expand" data-title="<?php echo $tooltip;?>">
      <div class="date_event">02.02.2017</div>
      <div style="text-align: center; width:232px;">
        	<div class="title_event">Some title</div>
      </div>
  </li>
</div>
</div>

最佳答案

那个li不需要,改成div就可以了

另外,为什么不直接添加一个隐藏的 div block 作为工具提示容器,在悬停时显示它(就像工具提示一样):

.expand:hover>div {
  display: none;
  height: 148px;
  width: 232px;
}

.mytitle {
  display: none;
}

.expand:hover>.mytitle {
  display: block;
  background: red;
}

/* Frame */

.frame {
  height: 150px;
  max-width: 1170px;
  /*line-height: 130px;*/
  /*  overflow:visible !important;*/
}

.frame ul {
  list-style: none;
  margin: 0;
  padding: 0;
  height: 100%;
  font-size: 14px;
}

.frame ul li {
  float: left;
  width: 232px;
  height: 100%;
  margin: 0 2px 0 0;
  padding: 0;
  background: #f1f1f1;
  color: #00b5f6;
  text-align: center;
  cursor: default;
  display: flex;
}

.frame ul li:hover {
  color: #fff;
  background: #00b5f6;
}


/* setup tooltips */

.tooltip {
  position: relative;
  z-index: 1;
}

li .tooltip {
  overflow: visible;
}

.tooltip:before,
.tooltip:after {
  position: absolute;
  display: inline-block;
  opacity: 0;
  pointer-events: none;
  width: 225px;
}

.tooltip:after {
  border-right: 6px solid transparent;
  border-top: 6px solid #00b5f6;
  border-left: 6px solid transparent;
  content: '';
  height: 0;
  top: -5px;
  left: 20px;
  width: 0;
  display: none;
}

.tooltip:before {
  background: #00b5f6;
  border-radius: 2px;
  color: #fff;
  content: attr(data-title);
  font-size: 12px;
  padding: 6px 10px;
  top: 0px;
  left: 0px;
  white-space: nowrap;
  height: 118px;
  max-width: 212px !important;
  display: block;
  word-wrap: break-word;
  text-align: left;
  white-space: pre-line;
}


/* expand */

.tooltip.expand:before {
  transform: scale3d(.2, .2, 1);
  transition: all .2s ease-in-out 0.5s;
}

.tooltip.expand:after {
  transform: translate3d(0, 6px, 0);
  transition: all .2s ease-in-out 0.5s;
}

.tooltip.expand:hover:before,
.tooltip.expand:hover:after {
  opacity: 1;
  transform: scale3d(1, 1, 1);
}

.date_event {
  text-align: left;
  width: 232px;
  position: absolute;
  padding: 5px 0 0 5px;
  font-style: italic;
  max-height: 20px;
  z-index: -1;
}

.suwak {
  width: 232px;
  height: 150px;
  margin-left: auto;
  margin-right: auto;
  overflow-y: visible;
  overflow-x: hidden;
  border: solid 1px #000;
}

.title_event {
  font-size: 16px;
  font-weight: bold;
  width: 232px;
  height: 130px;
  vertical-align: middle !important;
  display: table-cell !important;
  margin-left: auto;
  margin-right: auto;
}

.expand:hover>div {
  display: none;
}

.mytitle {
  height: 0px;
  width: 0px;
  display: none;
}

.expand:hover>.mytitle {
  height: 150px;
  width: 232px;
  display: block;
  background: red;
}
<div class="suwak">
  <div class="frame" id="basic">
    <div class="expand" data-title="">
      <div class="mytitle">my title <button>123</button><button>123</button></div>
      <div class="date_event">02.02.2017</div>
      <div style="text-align: center; width:232px;">
        <div class="title_event">Some title</div>
      </div>
    </div>
  </div>
</div>

关于php - 如何在工具提示中显示按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43958072/

相关文章:

javascript - 从外部 LAN 访问网络摄像机,无需端口转发

html - 为每个 CSS 分页符开始设置边距

javascript - 高分辨率智能手机和平板电脑的响应式 CSS

javascript - jQuery Datepicker 错误显示

php - Laravel 5,单击表单提交按钮时不显示任何内容

php - 动态生成 PayPal 按钮

c# - 从 Word 文档转换为 HTML

php 使用另一个 php 配置的模板文件?

html - <div> 中的圆孔

html - 绝对位置会导致图像比原来更大吗?