Laravel标签不可见

时间:2016-03-01 07:35:24

标签: php html5 laravel

我有这段代码:

 <div class="container col-md-6 col-md-offset-3">
        <div class="well well bs-component">
            <table class="table">
                <thead>
                    <tr>
                        <th>Logo</th>
                        <th>Bedrijfsnaam</th>
                        <th>Plaats</th>
                    </tr>
                </thead>
                <tbody>
                @foreach($companies as $company)
                    <a href="/bedrijf/{!! $company->CompanyId !!}">
                        <tr>
                                <td><img class="img-circle-company" src="{!! $company->Logo != null ? '/files/images/companylogos/'.$company->Logo : '/files/images/companylogos/default.png'!!}"/></td>
                                <td>{{ $company->CompanyName }}</td>
                                <td>{{ $company->City }}</td>
                        </tr>
                    </a>
                @endforeach
                </tbody>
            </table>
        </div>

但是a标签不起作用为什么会这样?在我的页面源中,它看起来像这样:

enter image description here

1 个答案:

答案 0 :(得分:1)

不幸的是,在锚中包装<tr>个元素并不是有效的HTML。有些浏览器可能不会眨眼,但大多数浏览器会删除有问题的元素。如果要继续使用表,另一个选项是在每个<td>元素中添加锚点。

 <div class="container col-md-6 col-md-offset-3">
     <div class="well well bs-component">
         <table class="table">
             <thead>
                 <tr>
                     <th>Logo</th>
                     <th>Bedrijfsnaam</th>
                     <th>Plaats</th>
                 </tr>
             </thead>
             <tbody>
             @foreach($companies as $company)
                 <tr>
                     <td>
                         <a href="/bedrijf/{!! $company->CompanyId !!}">                        
                             <img class="img-circle-company" src="{!! $company->Logo != null ? '/files/images/companylogos/'.$company->Logo : '/files/images/companylogos/default.png'!!}"/>
                         </a>
                     </td>
                     <td><a href="/bedrijf/{!! $company->CompanyId !!}">{{ $company->CompanyName }}</td>
                     <td><a href="/bedrijf/{!! $company->CompanyId !!}">{{ $company->City }}</a></td>
                 </tr>
             @endforeach
             </tbody>
         </table>
     </div>
 </div>