如何停用< br> tags in< div>由css? [英] How to disable <br> tags inside <div> by css?

查看:128
本文介绍了如何停用< br> tags in< div>由css?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

< br> 不会让我在内联显示3个按钮,所以我需要禁用它在div,我不能只是删除它们,他们

我有:

 < div style =display:block> 
< p>一些文字< / p>
< br>
< p>一些文字< / p>
< br>
< / div>

我想要:

 < div style =display:block> 
一些文本一些文本
< / div>

更多信息



我不想有mystyle.css文件。
当然我知道禁用它的方式。



我问如何添加到divs风格这个 br {display:none;



ol>
  • 不能删除< p> 标签,而不删除其中的内容。

  • 不可能通过divs风格直接隐藏< br> ,因此我这样做:




  •  < style type =text / css> 
    .mydiv {
    display:block;
    width:100%;
    height:10px;
    }
    .mydiv br {
    display:none;
    }
    < / style>

    < div class =mydiv>
    一些文本
    一些文本
    < / div>


    http://jsfiddle.net/cGT4E/

    解决方案

    例如

      div p,
    div br {
    display:inline;
    }

    http://jsfiddle.net/zG9Ax/



    或 - 我的评论者指出:

      div br {
    display:none;
    }

    但是为了实现你想要的示例,修剪 p 向下,因此:

      div br {
    display:none;
    }
    div p {
    padding:0;
    margin:0;
    }

    http://jsfiddle.net/zG9Ax/1


    <br> won't let me to display 3 buttons inline, so i need to disable it inside div, and I can't just delete them, they are automatically there.

    I have:

    <div style="display:block">
    <p>Some text</p>
    <br>
    <p>Some text</p>
    <br>
    </div>
    

    and I want:

    <div style="display:block">
    Some text Some text
    </div>
    

    More info

    I do not want to have mystyle.css file. Of course I know that way of disabling it.

    I asked how to add to divs style this br { display: none; } if it is possible.

    Solution:

    1. It is not possible to remove just <p> tags without removing content inside.
    2. It is not possible to hide <br> directly by divs style, so I make it this way:

    <style type="text/css">
    .mydiv {
    display: block;
    width: 100%;
    height: 10px;
    }
    .mydiv br {
    display: none;
    }
    </style>
    
    <div class="mydiv">
    Some text
    Some text
    </div>
    

    http://jsfiddle.net/cGT4E/

    解决方案

    You could alter your CSS to render them less obtrusively, e.g.

    div p,
    div br {
        display: inline;
    }
    

    http://jsfiddle.net/zG9Ax/

    or - as my commenter points out:

    div br {
        display: none;
    }
    

    but then to achieve the example of what you want, you'll need to trim the p down, so:

    div br {
        display: none;
    }
    div p {
        padding: 0;
        margin: 0;
    }
    

    http://jsfiddle.net/zG9Ax/1

    这篇关于如何停用&lt; br&gt; tags in&lt; div&gt;由css?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆