javascript - 如何在html中定义表格的宽度和高度?

标签 javascript jquery html css

如何在html中定义表格的宽度和高度?以及如何更改该链接的颜色和字体大小(用绿色覆盖字体), 我想让页面漂亮,project_list.html如下,非常感谢你的帮助:

{% extends 'base.html' %}

{% block content %}
  <nav aria-label="breadcrumb">
  </nav>
  <h3 class="mb-3">我学习的课程列表</h3>
  <div class="card">
    <table class="table mb-0">
      <thead>
        <tr>
          <th>课程序号</th>
          <th>课程名称</th>
          <th>部门名称</th>
          <th>课程日期</th>
          <th>课程时间</th>
          <th></th>
        </tr>
      </thead>
      <tbody>
        {% for course in courses %}
          <tr>
            <td class="align-middle">{{ course.pk }}</td>
            <td class="align-middle" style="word-break: break-all;"><a href="{% url 'employees:course_detail' course.pk%}">{{ course.name }}</a></td>
            <td class="align-middle">{{ course.department.get_html_badge }}</td>
            <td class="align-middle">{{ course.date }}</td>
            <td class="align-middle">{{ course.time }}</td>
          </tr>
        {% empty %}
          <tr>
            <td class="bg-light text-center font-italic" colspan="4">目前没有你所选技能的课程。</td>
          </tr>
        {% endfor %}
      </tbody>
    </table>
  </div>
<div class="card-footer">

最佳答案

至于宽度,我认为最简单的选择是为 thead 元素定义特定的宽度,比如

<thead>
    <tr>
        <th width="7%">课程序号</th>
        <th width="47%">课程名称</th>
        <th width="20%">部门名称</th>
        <th width="10%">课程日期</th>
        <th width="10%">课程时间</th>
        <th width="6%"></th>
    </tr>
</thead>

您可以根据生成的表格改变宽度。百分比宽度总是很难调整。

至于高度,它会相应地调整。我不建议您为行分配高度,因为如果内容的长度不同,它就无法正确调整。

至于链接颜色,我认为最简单的是:

<td class="align-middle" style="word-break: break-all;"><a href="{% url 'employees:course_detail' course.pk%}" style="color:blue;font-size:16px;">{{ course.name }}</a></td>

如果您使用 remem,您可以将 16px 替换为您需要的值。

关于javascript - 如何在html中定义表格的宽度和高度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51105578/

相关文章:

html - FF 中的 3D 效果按钮问题

javascript - 在成功的 ajax 请求上禁用 javascript 函数

javascript - Passport deserializeUser() 永远不会通过 Axios http 请求调用

javascript - jQM 1.5 新方法导致 jQuery Mobile 重定向失败

javascript - 不同类别图像的下一个和上一个按钮

javascript - 是否可以在直接图像而不是带有背景图像的 div 上实现这种缩放和平移效果?

html - 在 LESS 中获取属性值?

javascript - React Native BottomTabNavigator 删除空格

javascript - 将我的 php 数组转换为等效的 jQuery 数组

jquery - 不同的Wordpress特色图片叠加效果