2017-05-11 8 views
1

私はtdのセンターリンクに問題があります。問題は、このtdにリンクがいくつあるかわからないことです。ちょうど1つだけですが、14もあるかもしれません。彼らは水平に置かれます(しかし、あまりにも多くの場合、次の行に行く - 浮動小数点:私によって追加された左)。私はそれらを中心にすることはできません。右側のスペースは常にあります。特に、1つのリンクの幅が広く、別のラインに行く場合は、スペースがあります。私はクラスも.hour {display:inline-block}にしようとしましたが、小さなサイズではすべてのリンクが1行で表示されていません。そうする可能性はありますか?私にはわからないか、あなたは私を理解:Dセンターへのリンク方法

<div class="container"> 

    <div class="row"> 
     <div class="box"> 
      <div class="col-lg-12"> 
       <hr> 
       <h2 class="intro-text text-center">{{$doctorsDeadlines['lekarz']['imie']}} {{$doctorsDeadlines['lekarz']['nazwisko']}} 
       </h2> 
       <hr> 
       <hr class="visible-xs"> 
       <h4 class="text-center">Terminarz</h4> 
       <br/> 
       <div class="table-responsive"> 
        <table class="table table-striped table-bordered"> 
        <tr> 
         @foreach($doctorsDeadlines['terminy'] as $date => $hours) 
          <th class="text-center">{{$date}}</th> 
         @endforeach 
        </tr> 

        <tr> 
         @foreach($doctorsDeadlines['terminy'] as $date => $hours) 
         <td class="hour-container"> 
          <div class="hour-div"> 
          @foreach($hours as $hour) 
           <a class="hour" href="#">{{$hour}}</a> 
          @endforeach 
          </div> 

         </td> 
         @endforeach 
        </tr> 
       </table> 
      </div> 
     </div> 
    </div> 
    </div> 
</div> 

CSSコード:

.hour { 
color: white !important; 
background-color: #6699CC;!important; 
display: block; 
padding: 5px; 
float: left; 
text-align: center; 
margin: 3px; 
font-size: 15px; 
} 

.hour:hover { 
color: #000 !important; 
background-color: #dee1ed;!important; 
text-decoration: none; 
} 

.hour-div { 
border: 1px solid black; 
background-color: yellow; 
display: inline-block; 
} 
+0

 <table class="table table-striped table-bordered"> <tr> @foreach($doctorsDeadlines['terminy'] as $date => $hours) <th class="text-center">{{$date}}</th> @endforeach </tr> <tr> @foreach($doctorsDeadlines['terminy'] as $date => $hours) <td class="hour-container"> <div class="hour-div"> @foreach($hours as $hour) <a class="hour" href="../panel/wizyty/dodaj?id_lekarza={{$doctorsDeadlines['lekarz']['id']}}&data={{$date}}&godzina={{$hour}}">{{$hour}}</a> @endforeach </div> </td> @endforeach </tr> </table> 

を交換してください:中央 – slashsharp

+1

'テキスト整列:センター;'中心に置くtext/inline要素の親要素に適用する必要があります。あなたが中心にしたい要素の上に直接にはありません。また、アンカーをフローティングするとテキストの配置が無効になり、元に戻すことができます。 – hungerstar

答えて

-1

がそれか、他のコメントをお試しください。

あなたは、浮動要素を中央にフロートを削除し、TDのテキスト整列を与えることはできませんが、この

<table class="table table-striped table-bordered"> 
        <tr> 
         @foreach($doctorsDeadlines['terminy'] as $date => $hours) 
          <th class="text-center">{{$date}}</th> 
         @endforeach 
        </tr> 

        <tr> 
         @foreach($doctorsDeadlines['terminy'] as $date => $hours) 
         @foreach($hours as $hour) 
         <td class="hour-container"> 
          <div class="hour-div"> 

           <a class="hour" href="../panel/wizyty/dodaj?id_lekarza={{$doctorsDeadlines['lekarz']['id']}}&data={{$date}}&godzina={{$hour}}">{{$hour}}</a> 

          </div> 

         </td> 
         @endforeach 
         @endforeach 
        </tr> 
       </table> 
+0

しかし、私は浮動小数点数を削除すると、各リンクはセルの100%の幅で1行(垂直方向)に1行になりますが、リンクを1つずつ(水平方向に)したい、別の行に移動し、再度水平方向に移動します。 – wenus

+0

はい、進行 – ShriSun

+0

で仕事が回答 – ShriSun

関連する問題