【发布时间】:2018-07-04 16:57:32
【问题描述】:
如您所见,我在卡片内有一张图片,图片大小是固定的且已知的,但卡片文字长度可能会有所不同(短或过长)。 问题是我怎样才能防止卡片高度放大并强制它保持高度只包含图像并强制文本被包装和缩短。
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js" integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T" crossorigin="anonymous"></script>
<div class="container body-content">
<div class="card text-center">
<div class="card-header" style="text-align:right;font-weight:bold;font-size:large" dir="rtl">
<p style="padding-right:20px;margin-bottom:0px">Post Header</p>
</div>
<div class="card-body" style="padding-top:0px;padding-bottom:0px;padding-right:0px">
<div class="row">
<div class="col-9">
<p style="padding-top:20px;padding-bottom:20px;text-align:right;white-space: normal;" dir="rtl" class="card-text">
This Is Long Text This Is Long Text This Is Long Text This Is Long Text This Is Long Text This Is Long Text This Is Long TextThis Is Long Text This Is Long Text This Is Long Text This Is Long Text This Is Long Text This Is Long Text This Is Long Text This Is Long Text This Is Long Text
</p>
</div>
<div class="col-3">
<img class="img-fluid" src="http://fakeimg.pl/200/">
</div>
</div>
</div>
</div>
</div>
【问题讨论】:
-
你的意思是图片的高度适合文字高度吗?
-
@לבנימלכה 没有固定图像大小,卡片高度必须是适合图像而不是文本的值,现在如果文本太长,只需剪切文本而不放大以包含整个文本
标签: html css bootstrap-4