html - 隐藏 div 之外的文本

标签 html css twitter-bootstrap twitter-bootstrap-3

I have

我正在尝试创建上面的设计。这是我到目前为止所取得的成就,但我使用的是固定高度。

https://jsfiddle.net/iDaniel19/b0LL5wj8/1/

<div class="container">
<div class="row event">
    <div class="col-xs-3 col-sm-2 col-md-1 event-date">
        <h3>9</h3>
        <h3>May</h3>
    </div>
    <div class="col-xs-9 col-sm-10 col-md-1 no-padding-left event-info">
        <div class="event-info-title">
            <h4>Title</h4>
        </div>
        <div class="event-info-tl">
            <div class="event-info-tl-text">
                <p><span class="glyphicon glyphicon-time" aria-hidden="true"></span> Time</p>
                <p><span class="fa fa-map-marker" aria-hidden="true"></span>Post code</p>
            </div>
            <div class="event-info-tl-icon">
                <p class="event-icon"><span class="fa fa-chevron-right" aria-hidden="true"></span></p>
                <div style="clear: both;"></div>
            </div>
        </div>
    </div>
</div>

如何确保文本保持在一行而不显示在外面?

例如在上图中,底线(时间和地点)将无法在移动设备上显示,并且会超出容器

这是对图像进行编码的正确方法吗?

最佳答案

updated fiddle

尝试按以下方式进行操作——它不会在小型设备中中断,而是会创建一个新行。

.body {
    font-family: 'Open Sans';
}



.no-padding-left {
    padding-left:0;
}

.float-right {
    float:right;
}
.event{
    height:70px;
}
.event-date {
    border-right: 1px solid black;
    text-align: center;
}

.event-date > h3 {
    font-weight: bold;
    text-transform: uppercase;
    padding:0;
    margin:0;
    line-height: 34px;
}

.event-info-title {
    height: 35px;
}

.event-info-title > h4{
    padding: 0 0 0 5px;
    font-weight: 600;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin:0;
    top:25%;
    position: relative;
}

.event-info-tl {
    height: 35px;
    border-top: 1px solid black;
}
.event-info-tl > div {
    display: inline-block;
}

.event-info-tl-text {
    top:25%;
    position: relative;
}

.event-info-tl-text > p {
    display: inline-block;
    margin: 0;
}
.event-info-tl-text > p:first-child{
    padding-left: 5px;
}
.event-info-tl-icon {
    float:right;
    margin:0;
}
.event-icon {
    padding:5px;
    font-size: 20px;
    margin:0;
}

@media (max-width: 576px) {
    .container {
        padding:0;
    }
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<div class="container">
    <div class="row event">
        <div class="col-xs-3 col-sm-2 col-md-1 event-date">
            <h3>9</h3>
            <h3>May</h3>
        </div>
        <div class="col-xs-9 col-sm-10 col-md-1 no-padding-left event-info">
            <div class="event-info-title">
                <h4>Title</h4>
            </div>
            <div class="event-info-tl ">
                <div class="event-info-tl-text ">
                <div class="col-xs-12 col-sm-6">
                
               
                    <p><span class="glyphicon glyphicon-time" aria-hidden="true"></span> Time</p>
                     </div>
                     <div class="col-xs-12 col-sm-6">
                    <p><span class="fa fa-map-marker" aria-hidden="true"></span>Post code</p>
                     </div>
                </div>
                <div class="event-info-tl-icon">
                    <p class="event-icon"><span class="fa fa-chevron-right" aria-hidden="true"></span></p>
                    <div style="clear: both;"></div>
                </div>
            </div>
        </div>
    </div>
</div>

关于html - 隐藏 div 之外的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42894129/

相关文章:

html - 页脚出现在两个页面的错误位置(其他没问题)

html - 以 HTML 形式包含事件的 Bootstrap 选项卡

html - Bootstrap 导航栏图标栏不起作用

php - 找不到用于元素编辑的 css 行

html - 图片链接到另一张图片(图片库)

html - CSS 中美元符号的语法文档?

css - Bootstrap 4 卡相同高度和底部对齐

css - 如何不使用 SASS 和 bootstrap 将所有 CSS 合并到一个文件中

html - 对于此表,溢出和省略号在 IE 中不起作用

javascript - 以 Angular 登录后显示 Bootstrap 导航栏并应用路由功能