标题文本从包装器中逃脱

时间:2018-02-19 17:31:07

标签: html css laravel-blade

在移动设备上,标题文本从div包装器中转义。我该怎样预防呢?只有当剩下2个字符时才会发生。如果可能的话,只使用纯CSS(如果需要的话,jQuery)。

Intro to Neural Networks

HTML(Laravel-Blade)

@section('content')
@if($builds)
    @foreach($builds as $result)
        <div class="col-md-4">
            <div class="builds">   
                <img src="{{ $result->icon }}" class="img-responsive" alt="Hero icon" />
                <div class="text">
                    <h2>{{ $result->name }} - {{ $result->build }}</h2>
                    <i><span class="usercolored">{{ $result->created_by }} </span>,{{ date('d-m-Y', strtotime($result->date)) }} <br /> {{ $result->views }} zobrazení</i><br />
                    <button class="btn btn-primary btn-md">Přejit na build</button>
                </div>               
            </div>
        </div>
    @endforeach
@else
    <p>Nic nenalezeno</p>
@endif
@endsection

CSS

.builds {
    box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2);
    height: 191px;
    margin-top: 10px;
}

.builds h2{
    margin: 0;
}

.builds:hover {
    box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2);
}

.builds img {
    width: 171px;
    height: 191px;
    float: left;
}

.builds .text {
    margin-left: 180px;
}

2 个答案:

答案 0 :(得分:0)

.builds h2{
  word-wrap: break-word;
  //word-break: break-all;
}

我已经为您了解了它的工作原理。例如,在一个相对较小的容器内,一个非常长的单词很有用,这个容器不合适。

&#13;
&#13;
div {
   width: 100px;
   border: 1px solid red;
}

/* word-wrap: break-word recently changed to overflow-wrap: break-word. */
.overflow {
  /* A long word/string will break in random places.
  A hyphen character will not be inserted. */
  overflow-wrap: break-word;
}

/* A very long word WILL NOT start at the point it should start. 
It will be wrapped to next line and then being broken. */
.word-wrap {
  word-wrap: break-word;
}

/* Avery long word starts at the point it 
should start and it is being broken. */
.word-break {
  word-break: break-all;
}
&#13;
Normal: 
<div>I am a text that 0123456789012345678901234567890123456789</div><br>

overflow-wrap: break-word; 
<div class="overflow">I am a text 000001234567890123456789</div><br>

word-wrap: break-word;
<div class="word-wrap">I am a text 000001234567890123456789</div><br>

word-break: break-all;
<div class="word-break">I am a text 000001234567890123456789</div><br>
&#13;
&#13;
&#13;

答案 1 :(得分:0)

试试这个

word-break: break-all;