【问题标题】:Remove URL from printing page using css使用 css 从打印页面中删除 URL
【发布时间】:2017-02-15 17:53:18
【问题描述】:
<body>
 <div class="print-logo">
  <img class="print-logo img-responsive" id="logo" src="http://logo.png" alt="image" /></div>
    <div class="print-site_name">Published on <em class="placeholder">website name</em> (<a href="http://localhost">http://localhost</a>)</div>
<p />
<div class="print-breadcrumb"><a href="/">Home</a> Reportedly Prepping </div>
<hr class="print-hr" />
    <div class="print-content"><article id="node-ID" class="node node-blog clearfix">   
<div class="bd-headline left"> some title  </div>    
<div class="item-body">
 <p dir="ltr"><span id="docs-internal-guid-???">    
  <img alt="Core" height="366" src="http://image.png" width="645" />  
   <span> contributor helping  report. It’s the latest nightmare.</span><a href="http://url-to-be-removed">some text for the url to be removed(http://url-to-be-removed) then some more text.  
 </p>   
 <p> some more text and another url</p>
</div>   
...   

使用 CSS 如何删除 URL。由于 URL 在正文中,我尝试使用类名和 html 标记:

div.print-content article.node .node-blog .clearfix div.item-body p a { content: "";}   

更新
我要删除的部分是 bold
贡献者帮助报告。这是最新的噩梦。some text for the url to be removed (http://url-to-be-removed) 然后是更多的文字。

【问题讨论】:

标签: html css printing


【解决方案1】:

要从印刷媒体中删除 URL,请使用:

@media print {
  div.print-content article.node .node-blog .clearfix div.item-body p a {
    display: none;
}

如果您想要让它完全消失(从任何角度来看),只需添加 div.print-content article.node .node-blog .clearfix div.item-body p a { display: none; }

以这种方式添加它会将其从文档视图中完全删除,从而释放 &lt;a&gt; 标记占用的所有空间。

【讨论】:

  • 感谢我所做的是:div.print-content article.node div.item-body p a { display: none; } 但它删除了所有内容:链接和网址。我更新了我的问题并将需要删除的部分加粗,即括号中链接后面的 URL。
【解决方案2】:

a[href]:after { content: none !important; }

更新

CSS :after 选择器在每个选定元素的内容之后插入一些内容。

使用 content 属性指定要插入的内容。 content: none 用于明确防止生成 after 选择器(伪元素)(实际上仅用于覆盖另一种会生成内容的样式)。

a[href]:after { content: none !important; } 表示删除每个链接后的内容。

【讨论】:

    猜你喜欢
    • 2010-10-09
    • 2012-10-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-03
    • 2016-03-05
    • 1970-01-01
    相关资源
    最近更新 更多