html - 按钮显示问题

标签 html css button filter

我有点击按钮触发的标签过滤器列表,问题是当有 2 行或更多行过滤器时,事件过滤器总是将第二行上的过滤器推到右边。例如,如果您打开 fiddle ,单击并且不会在“城市”上释放鼠标按钮,您会注意到这种令人不快的行为。

JSFiddle:https://jsfiddle.net/Hyg3C/4497/

HTML

  <h3>Composition</h3>
  <div class="ui-group">
    <div class="button-group js-radio-button-group" data-filter-group="composition">
      <button class="button is-checked" data-filter="">All</button>
      <button class="button" data-filter=".landscape">Landscape</button>
      <button class="button" data-filter=".portait">Portrait</button>
      <button class="button" data-filter=".square">Square</button>
    </div>
  </div>

  <h3>People</h3>
  <div class="ui-group">
    <div class="button-group js-radio-button-group" data-filter-group="people">
      <button class="button is-checked" data-filter="">All</button>
      <button class="button" data-filter=".people">People</button>
      <button class="button" data-filter=".nopeople">No People</button>
    </div>
  </div>

  <h3>Theme</h3>
  <div class="ui-group">
    <div class="button-group js-radio-button-group" data-filter-group="theme">
      <button class="button is-checked" data-filter="">All</button>
      <button class="button" data-filter=".nature">Nature</button>
      <button class="button" data-filter=".fashion">City</button>
      <button class="button" data-filter=".mountains">Mountains</button>
      <button class="button" data-filter=".sea">Sea</button>
      <button class="button" data-filter=".sunset">Sunset</button>
      <button class="button" data-filter=".rain">Rain</button>
    </div>
  </div>

  <h3>Place</h3>
  <div class="ui-group">
    <div class="button-group js-radio-button-group" data-filter-group="place">
      <button class="button is-checked" data-filter="">All</button>
      <button class="button" data-filter=".nature">Barcelona</button>
    </div>
  </div>

</div>
</div>

CSS

/********************************
Filter
*********************************/

ul#composition.filter, ul#people.filter, ul#theme.filter {
    max-width: 80%;
    margin-left: 10%;
}

h3 {
  font-family: Source Sans Pro, sans-serif;
  font-size: 17px;
  font-weight: 400;
  color: #434343;
}



/********************************
Sidebar
*********************************/



#sidebar-wrapper  {
    top: 0;
    background: rgb(250,250,250);
}

.start {
    display: none;
}

#sidebar {
    padding-left: 0;
    -webkit-transition: all 0.5s ease;
    -moz-transition: all 0.5s ease;
    -o-transition: all 0.5s ease;
    transition: all 0.5s ease;
}

#sidebar.toggled {
    padding-left: 250px;
}

#sidebar-wrapper {
    z-index: 1000;
    position: fixed;
    left: 250px;
    width: 0;
    height: 100%;
    margin-left: -250px;
    overflow-y: auto;

    -webkit-transition: all 0.5s ease;
    -moz-transition: all 0.5s ease;
    -o-transition: all 0.5s ease;
    transition: all 0.5s ease;
}

#sidebar.toggled #sidebar-wrapper {
    width: 250px;
}

#page-content-wrapper {
    width: 100%;
    position: absolute;
    padding: 15px;
}

#sidebar.toggled #page-content-wrapper {
    position: absolute;
    margin-right: -250px;
}

/* Sidebar Styles */

.sidebar-nav {
    position: absolute;
    top: 0;
    width: 250px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.sidebar-nav li {
    text-indent: 20px;
    line-height: 40px;
}

.sidebar-nav li a {
    /*display: block;*/
    text-decoration: none;
    color: #999999;
}

.sidebar-nav li a:hover {
    text-decoration: none;
    color: #fff;
    background: rgba(255,255,255,0.2);
}

.sidebar-nav li a:active,
.sidebar-nav li a:focus {
    text-decoration: none;
}

.sidebar-nav > .sidebar-brand {
    height: 65px;
    font-size: 18px;
    line-height: 60px;
}

.sidebar-nav > .sidebar-brand a {
    color: #999999;
}

.sidebar-nav > .sidebar-brand a:hover {
    color: #fff;
    background: none;
}

@media(min-width:768px) {
    #sidebar {
        padding-left: 250px;
    }

    #sidebar.toggled {
        padding-left: 0;
    }

    #sidebar-wrapper {
        width: 250px;
    }

    #sidebar.toggled #sidebar-wrapper {
        width: 0;
    }

    #page-content-wrapper {
        padding: 20px;
        position: relative;
    }

    #sidebar.toggled #page-content-wrapper {
        position: relative;
        margin-right: 0;
    }


@media(min-width:1366px) {
    #sidebar {
        padding-left: 24.45%;
    }

    #filter {
        max-width: 82.44%;
        margin-left: 8.78%;
    }

    #sidebar.toggled {
        padding-left: 0;
    }

    #sidebar-wrapper {
        width: 24.45%
    }
}

@media(min-width:1666px) {
    #sidebar {
        padding-left: 17.88%;
    }

    div.filters {
        max-width: 82.44%;
        margin-left: 8.78%;
    }

    #sidebar.toggled {
        padding-left: 0;
    }

    #sidebar-wrapper {
        width: 17.88%;
    }
}





.button {
  position: relative;
  float: left;
  font-family: Source Sans Pro, sans-serif;
  font-size: 16px;
  font-weight: 300;
  display: inline-block;
  background: #fff;
  border: none; 
  color: rgb(230,230,230);
  font-family: sans-serif;
  font-size: 16px;
  text-shadow: 0 1px white;
  cursor: pointer;
  padding: 0;
  margin: 0 8px 8px 0;
}

.button:hover {
  color: #434343;
  -webkit-transition: color 1s;
  transition: color 1s;
}

.button:active,
.button.is-checked {
  border-bottom: 1px solid #434343;
  background-image: none;
  outline: 0;
  -webkit-box-shadow: none;
          box-shadow: none;

}

.button.is-checked {
  color: #434343;
}

.button:active {
  color: #434343;
  border-bottom: 1px solid #434343;
}



/* ---- button-group ---- */

.button-group:after {
  content: '';
  display: block;
  clear: both;
}

.button-group .button {
  float: left;
  border-radius: 0;
}

最佳答案

像这样尝试: Demo

.button {
        font-family: Source Sans Pro, sans-serif;
        font-size: 16px;
        font-weight: 300;
        display: inline;
        background: #fff;
        border: none;
        color: rgb(230, 230, 230);
        font-family: sans-serif;
        font-size: 16px;
        text-shadow: 0 1px white;
        cursor: pointer;
        padding: 0;
        margin: 0 8px 8px 0;
        height:22px; /* specify height 2 solve this problem */
    }

关于html - 按钮显示问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32714188/

相关文章:

javascript - 函数中的按钮 onclick

php - 文件上传适用于桌面,但不适用于使用相机的移动设备

css - 样式文本区域和按钮

两个 Div 之间的 CSS 水平空间问题

css - 在 html 页面中更改正文背景的可能性

ios - Swift 3 中的 UIAlertController 按钮操作

jquery - 是否可以在纯 html 5 中创建它

html - 标签略低于文本输入

jquery - CSS 和 jQuery 图像 slider

c# - Xamarin 在某些情况下不显示图像