【问题标题】:Pseudo-element after not showing? [duplicate]伪元素后不显示? [复制]
【发布时间】:2013-03-24 21:12:29
【问题描述】:

我想在一些打开工具提示的表单域末尾添加一个帮助徽标。

一切正常,但 .helptip 图标 (http://img1.wsimg.com/shared/img/1/small-help-icon.gif) 与文本出现在左侧(合并)。我实际上想要在跨度文本的右侧,所以我做了 .help-tip:after。但随后什么都没有出现。

你能看出哪里不对吗?

<div class="advancedSearchFormSelectField fclear">
<span id="view_format_mis" class="advancedSearchFormlabel help-tip"> Include Columns in Result Set </span>

<select class="advancedSearchFormSelectBox" id="filters_include_columns" multiple="multiple" name="filters[include_columns][]">

<option value="x">X</option>
<option value="y">Y</option>
<option value="z">Z</option>
</select>
</div>

<div class="advancedSearchFormSelectField fclear">
<span id="view_format_mis" class="advancedSearchFormlabel"> Sort Column </span>
<!--No help tip here -->    
<select class="advancedSearchFormSelectBox" id="filters_sort_columns" multiple="multiple" name="filters[sort_columns]">

<option value="a">A</option>
<option value="b">B</option>
<option value="c">C</option>
</select>
</div>
.help-tip {
/* Merged text at the moment. .help-tip:after not working */ 
    cursor: pointer;
    width: 10px;
    height: 10px;
    background-repeat: no-repeat;
    background-image: url("/assets/small-help-icon.gif");
}

.advancedSearchFormSelectField{
    width:300px;
    margin: 5px;
    height: 60px;
    float:left;
}

【问题讨论】:

  • 你的“后”课在哪里?你用什么浏览器?
  • 快速注释以避免其他人犯同样的愚蠢错误:如果外部元素将overflow 设置为hidden,则:after 伪元素将不会显示...跨度>
  • 对我来说问题是在图像标签上不起作用

标签: css pseudo-element


【解决方案1】:

您目前似乎没有使用伪元素。试试这个设置.help-tip.help-tip::after 并给出content: ""display: inline-block

.help-tip::after {
    content: "";
    display: inline-block;
    cursor: pointer;
    width: 10px;
    height: 10px;
    background-repeat: no-repeat;
    background-image: url("/assets/small-help-icon.gif");
}

【讨论】:

  • 嘿,它显示得很完美。我认为这是 display:inline-block 的原因。但是,一个问题是 $(".help-tip").live ('click',function().....,当您单击 gif 时不再起作用。单击文本时它正在起作用。什么我应该这样做吗?
  • 更新 - 在 Firefox 中工作但不在 Chrome 中...为什么?
  • 很难说没有看到一个例子,一切看起来都很好,所以它可能是一些小东西。
  • 对我来说,它只适用于 content: ''; 而不适用于 content: "";
猜你喜欢
  • 1970-01-01
  • 2018-10-30
  • 2020-02-15
  • 1970-01-01
  • 2016-05-24
  • 2017-10-24
  • 2015-09-12
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多