如何使部分增长以在CSS Grid中包装内容?

时间:2018-08-23 19:54:29

标签: html css html5 css3 css-grid

如何使<section></section>成长为适合CSS网格布局的内容?

screenshot of page

右侧的深蓝色部分应在黄色高亮显示的地方结束。换句话说,它应该环绕其内容。我不确定如何才能做到这一点。

我已经创建了a Codepen

这是HTML:

<div class="deity-details">
  <header>
    <div class="breadcrumbs">
      <a asp-controller="Home" asp-action="Index" class="breadcrumb__item">Home</a> /
      <a href="#" class="breadcrumb__item">Deities</a> /
      <a asp-controller="Deity" asp-action="Details" asp-route-slug="@Model.Slug" class="breadcrumb__item">@Model.Name</a>
    </div>
    <h1 class="deity-name h1__white">@Model.Name</h1>
  </header>

  <section class="deity-description">
    @Html.Raw(Model.Description)
  </section>

  <section class="deity-meta">
    <div class="attributes">
      <div class="attribute">
        <label class="attribute-label">Origin</label>
        <h4 class="attribute-value">@Model.Origin</h4>
      </div>
      <div class="attribute">
        <label class="attribute-label">Aliases</label>
        <h4 class="attribute-value">@Model.Aliases</h4>
      </div>
      <div class="attribute">
        <label class="attribute-label">Sex</label>
        <h4 class="attribute-value">@Model.Sex</h4>
      </div>
    </div>
  </section>
</div>

这是SCSS:

.deity-details {
  height: 100vh;
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  grid-template-rows: repeat(10, 1fr);
}

header {
  grid-column: 1 / span 10;
  grid-row: 1 / span 2;
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  grid-template-rows: 50px 1fr;
  background: $dark-navy;
}

.breadcrumbs,
.deity-name {
  grid-column: 3 / span 6;
}

.breadcrumbs {
  display: flex;
  align-items: center;
  color: $white;
  font-family: "Roboto Slab", sans-serif;
}

.breadcrumb__item {
  color: $white;
  font-family: "Roboto Slab", sans-serif;
  letter-spacing: 1px;
  margin: 0 10px 0 10px;
  font-size: 0.9rem;
}

.breadcrumb__item:first-child {
  margin-left: 0
}

.deity-name {
  display: flex;
  align-items: center;
  letter-spacing: 3px;
}

.deity-description {
  grid-column: 3 / span 3;
  grid-row: 3 / span 8;
  padding: 30px 0 0 0;
}

.deity-meta {
  grid-column: 7 / span 2;
  grid-row: 3 / span 6;
  background: $dark-navy;
  border-bottom-left-radius: $border-radius;
  border-bottom-right-radius: $border-radius;
  padding: 30px 50px 0 50px;
}

.attribute {
  margin: 0 0 20px 0;
  border-bottom: 2px solid $light-blue;
  padding: 0 0 20px 0;
}

.attribute:last-child {
  border: none;
}

.attribute-label {
  display: block;
  font-family: "Abel", sans-serif;
  color: $light-blue;
  font-size: 1.1rem;
  text-transform: uppercase;
  margin: 0 0 5px 0;
  letter-spacing: 2px;
}

.attribute-value {
  color: $white;
  font-size: 2.2rem;
  font-family: "Playfair Display", serif;
  line-height: 4rem;
}

1 个答案:

答案 0 :(得分:1)

答案很可能是问题本身。

  

如何使部分增长以在CSS Grid中包装内容?

您在问如何调整内容大小。这通常涉及public function notifications_data($col) { $notifications = $this->notifications() ->where('data','LIKE','%"appointment_id":"0"%') ->orWhere('data','LIKE','%"status":"0"%') ->get(); return ($notifications); } 的大小。

在代码中,您使用oFileLocation = \\data\shares\folder1\file.iso strCmdText = "/c \"C:\\Program Files\\7-Zip\\7z.exe\" x -tiso -y " + oFileLocation + " -o" + oDownloadDirectory + "\\" + oFileNameReplaced; ProcessStartInfo startInfo = new ProcessStartInfo("CMD.exe"); startInfo.WindowStyle = ProcessWindowStyle.Maximized; startInfo.Arguments = strCmdText; Process.Start(startInfo).WaitForExit(); 单位设置行大小:

auto

fr单元与内容没有直接关联。它仅考虑自由空间。

如果您希望跟踪内容大小,请改用grid-template-rows: repeat(10, 1fr) fr

auto

revised codepen