容器内的响应文本

时间:2017-10-17 14:34:32

标签: css twitter-bootstrap responsive-design

根据此代码:

HTML



.conteudo-wrapper {
  padding-left: 280px;
}

.card {
  border-radius: 4px;
  display: block;
  margin-bottom: 25px;
  overflow: hidden;
  color: #fff;
  height: 120px;
  position: relative
}

.card:hover,
.card:active,
.card:focus,
.card:visited {
  color: #fff;
  text-decoration: none;
}

.card-roxo {
  background-color: #8E44AD;
}

.card-verde {
  background-color: #32C5D2;
}

.card-azul {
  background-color: #3598DC;
}

.card-vermelho {
  background-color: #E7505A;
}

.card-amarelo {
  background-color: #FBBE27
}

.card .visual {
  display: block;
  float: left;
  font-size: 35px;
  height: 80px;
  line-height: 35px;
  padding-left: 15px;
  padding-top: 35px;
  width: 80px;
}

.card .visual i {
  color: #ffffff;
  opacity: 0.1;
  font-size: 110px;
  line-height: 110px;
  margin-left: -35px;
}

.card .detalhe {
  padding-right: 15px;
  position: absolute;
  right: 15px;
}

.card .detalhe .numero {
  font-size: 34px;
  font-weight: 300;
  letter-spacing: -1px;
  line-height: 36px;
  margin-bottom: 0;
  padding-top: 25px;
  text-align: right;
}

.card .detalhe .descricao {
  font-size: 16px;
  font-weight: 300;
  letter-spacing: 0;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
}

.card .detalhe .data-referencia {
  font-size: 12px;
  margin-top: 8px;
  text-align: right;
}

.card .detalhe .nome-link {
  font-size: 18px;
  font-weight: bold;
  margin-top: 40px;
}

<div class="conteudo-wrapper ">

  <div class="col-lg-3 col-md-6 col-sm-6 col-xs-12">
    <a href="javascript:void(0);" class="card card-roxo">
      <div class="visual">
        <i class="fa fa-bar-chart-o"></i>
      </div>
      <div class="detalhe arrecadacao-liquida">
        <div class="numero">-184 mi<span class="contador" id="contadorArrecadacaoLiquida"></span></div>
        <div class="descricao">Retorno dos Financiamentos</div>
        <div class="data-referencia">Posição: 2017</div>
      </div>
    </a>
  </div>

  <div class="col-lg-3 col-md-6 col-sm-6 col-xs-12">
    <a href="javascript:void(0);" class="card card-verde">
      <div class="visual">
        <i class="fa fa-bar-chart-o"></i>
      </div>
      <div class="detalhe contratacoes">
        <div class="numero"><span class="contador" id="contadorContratacoes"></span></div>
        <div class="descricao"></div>
        <div class="data-referencia"></div>
      </div>
    </a>
  </div>

  <div class="col-lg-3 col-md-6 col-sm-6 col-xs-12">
    <a href="javascript:void(0);" class="card card-amarelo">
      <div class="visual">
        <i class="fa fa-bar-chart-o"></i>
      </div>
      <div class="detalhe retorno-financiamentos">
        <div class="numero"><span class="contador" id="contadorRetornoFinanciamentos"></span></div>
        <div class="descricao"></div>
        <div class="data-referencia"></div>
      </div>
    </a>
  </div>

  <div class="col-lg-3 col-md-6 col-sm-6 col-xs-12">
    <a href="javascript:void(0);" class="card card-vermelho">
      <div class="visual">
        <i class="fa fa-bar-chart-o"></i>
      </div>
      <div class="detalhe taxa-administracao">
        <div class="numero"><span class="contador" id="contadorTaxaAdministracao"></span></div>
        <div class="descricao"></div>
        <div class="data-referencia"></div>
      </div>
    </a>
  </div>
</div>
&#13;
&#13;
&#13;

另见this Fiddle

当同一行中有4张牌时(你必须拖动分割器),描述文本会大于卡的限制并截断。

为了解决这个问题,我尝试使用Viewport Percentage Lengths,但是当设备分辨率较低时,由于引导网格系统卡会变大,字体变得太小。考虑到此描述的文本是动态的,我需要创建一个系统,使该文本在容器内响应,也就是说,当文本大于容器时,字体会减小直到它适合。

我该如何解决这个问题?有没有解决方案只使用css?

0 个答案:

没有答案