删除空paragrapf并更改h3元素css

时间:2017-11-08 12:52:11

标签: html css

我在wordpress网页上有一些博客。可以从仪表板添加这些博客。问题是新博客会生成一些弄乱设计的html元素。

这是生成的hml:

<div class="loop-entry-excerpt entry clr" style="position: absolute;">
    <p></p>
    <h3>Creating a Culture of Innovation</h3>
      Last week, I had the opportunity...
   <p></p>
   <div class="button_Read_More text-right">
       <a href="http://staging.princetonpartners.com/tips-from-googleplex/"><span id="readMore_button" class="blog_readmore">Read more</span></a>
        </div>
     </div>

问题在于<p></p>这两段,并且文本位于h3元素中。该文本应位于<p>

应该是:

<div class="loop-entry-excerpt entry clr" style="position: absolute;">

    <p>Creating a Culture of Innovation
      Last week, I had the opportunity...</p>

   <div class="button_Read_More text-right">
       <a href="http://staging.princetonpartners.com/tips-from-googleplex/"><span id="readMore_button" class="blog_readmore">Read more</span></a>
        </div>
     </div>

请告诉我如何用css解决这个问题?我可以用纯css做到这一点吗?谢谢!

1 个答案:

答案 0 :(得分:3)

  

我可以用纯CSS进行此操作吗?

我对此表示怀疑,但在jQuery下面可能有所帮助

jQuery(function($){
  $(document).ready(function(){
  $('h3').each(function(){
    $(this).replaceWith('<p>'+$(this).text()+'<p>');
  });
  $('p').each(function(){
    if(!$(this).text().length){
    $(this).remove();
  }
  });

});
});

查看小提琴[ here ]