首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为自定义下拉框调整css宽度

为自定义下拉框调整css宽度
EN

Stack Overflow用户
提问于 2014-01-03 15:42:20
回答 1查看 949关注 0票数 0

这是我要为自己工作的下拉框。但它从左边的边界消失了。实际上,菜单项应该正好在文本框下面。

检查Fiddle

我试图更改所有元素的宽度,但无法设置它。有人能告诉我在弹出下拉框时,哪个类精确地控制菜单项的宽度吗?

css:

代码语言:javascript
复制
.container {
    width:90%;
    margin:10% auto;
}
.dropdown-menu{
    width:85%;
    margin:0 auto;
}
.twitter-typeahead .tt-query, .twitter-typeahead .tt-hint {
    margin-bottom: 0;
    width: 360px; !important;
}
.twitter-typeahead .tt-hint {
    display: block;
    height: 34px;
    padding: 6px 12px;
    font-size: 14px;
    line-height: 1.428571429;
    border: 1px solid transparent;
    border-radius:4px;
}
.twitter-typeahead .hint-small {
    height: 30px;
    padding: 5px 10px;
    font-size: 12px;
    border-radius: 3px;
    line-height: 1.5;
}
.twitter-typeahead .hint-large {
    height: 45px;
    padding: 10px 16px;
    font-size: 18px;
    border-radius: 6px;
    line-height: 1.33;
}
.tt-dropdown-menu {
    min-width: 260px;
    margin-top: 2px;
    padding: 5px 0;
    background-color: #fff;
    border: 1px solid #ccc;
    border: 1px solid rgba(0, 0, 0, .2);
    *border-right-width: 2px;
    *border-bottom-width: 2px;
    -webkit-border-radius: 6px;
    -moz-border-radius: 6px;
    border-radius: 6px;
    -webkit-box-shadow: 0 5px 10px rgba(0, 0, 0, .2);
    -moz-box-shadow: 0 5px 10px rgba(0, 0, 0, .2);
    box-shadow: 0 5px 10px rgba(0, 0, 0, .2);
    -webkit-background-clip: padding-box;
    -moz-background-clip: padding;
    background-clip: padding-box;
}
.tt-suggestion {
    display: block;
    padding: 3px 20px;
}
.tt-suggestion.tt-is-under-cursor {
    color: #fff;
    background-color: #0081c2;
    background-image: -moz-linear-gradient(top, #0088cc, #0077b3);
    background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0077b3));
    background-image: -webkit-linear-gradient(top, #0088cc, #0077b3);
    background-image: -o-linear-gradient(top, #0088cc, #0077b3);
    background-image: linear-gradient(to bottom, #0088cc, #0077b3);
    background-repeat: repeat-x;
    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0088cc', endColorstr='#ff0077b3', GradientType=0)
}
.tt-suggestion.tt-is-under-cursor a {
    color: #fff;
}

.tt-suggestion p {
    margin: 0;
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-01-03 15:46:35

在您的类.dropdown-menu上添加以下内容:

代码语言:javascript
复制
.dropdown-menu{
  width:360px;
  left:auto;
  margin:0 auto;
}

小提琴演示

这是因为360px是输入.twitter-typeahead .tt-query, .twitter-typeahead .tt-hint的大小。

left:auto保持原来的距离,无论绝对位置。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20907350

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档