Bootstrap3 .visible-* .hidden-* display inline

后端 未结 4 808
挽巷
挽巷 2020-12-29 01:26

Bootstrap has some nice .visible-* (eg. .visible-lg) class utility for selecting what to show or hide depending on the screen size.

When us

相关标签:
4条回答
  • 2020-12-29 01:38

    Updating to bootstrap 3.1 or above indeed solves the problem as from this point on the hidden- classes only hide the tag and don't set display: block anymore. This way you can use <div> for block context and <span> for inline-block context (the normal behavior of these tags)

    0 讨论(0)
  • 2020-12-29 01:39

    This has been sort of fixed in v3.1.

    .visible-lg or .visible-md will force display: block !important; but using .hidden-xs or .hidden-sm will display inline.

    0 讨论(0)
  • 2020-12-29 01:48

    The following library extends the visible helper classes with inline & inline-block variations:

    https://github.com/moappi/bootstrap.inline-responsive

    Implements the following:

    • visible-inline-*
    • hidden-inline-*

    and

    • visible-inline-block-*
    • hidden-inline-block-*
    0 讨论(0)
  • 2020-12-29 02:00

    Update for Bootstrap v3.2.0

    This is now natively solved in Bootstrap v3.2.0 with this commit

    According to the new responsive classes documentation:

    As of v3.2.0, the .visible-- classes for each breakpoint come in three variations, one for each CSS display property value listed below:

    Group of classes          | CSS display
     .visible-*-block         |  display: block;
     .visible-*-inline        |  display: inline;
     .visible-*-inline-block  |  display: inline-block;
    

    For example, you could use:

    <p>Device is: <span class="visible-lg-inline">Large</span></p>
    

    Other Instances

    Asked about on Stackoverflow:

    • Bootstrap 3 class visible-lg moves span to a new line

    Reported in Bootstrap Issues:

    • #4929 - Responsive utility classes may cause unexpected wrapping
    • #7808 - Using display inherit in responsive utilities causes elements to be wrongly displayed
    • #8500 - responsive class usage with inline element
    • #8869 - responsive .hidden-* classes change from display block to inline-block
    • #10263 - visible-xs makes display=block even for inline elements
    0 讨论(0)
提交回复
热议问题