AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-878701

gregsdennis's questions

Martin Hope
gregsdennis
Asked: 2024-11-18 09:56:51 +0800 CST

垂直居中,但在内容扩展时保持上边距

  • 6

我有一个包含两列的弹性框。左侧内容通常比右侧内容高,我想将右侧内容渲染为居中。

但是,左侧的内容可以扩展,我想让右侧的内容在扩展时保持在原处,而不是保持居中。

到目前为止,我有第一部分,但是当左侧部分扩展时,右侧部分会下降以保持居中。

.host {
  width: 500px;
  padding: 5px;
  display: flex;
  flex-direction: row;
  align-items: center;
  background: yellow;
}

.left-panel {
  width: 50%;
  margin: 5px;
  flex-direction: column;
  background: pink;
}

.summary {
  margin: 5px;
  background: green;
}

.expand-list {
  margin: 5px;
  background: skyblue
}

.right-panel {
  width: 50%;
  margin: 5px;
  display: flex;
  flex-direction: row;
  background: blue;
}

.image {
  margin: 5px;
  background: red;
}

button {
  margin: auto 5px;
  width: 100px;
}
<div class="host">
  <div class="left-panel">
<div class="summary">
  Here is a long paragraph of text that I need to display.
  It takes up most of the container, but there's an expander
  below that will make this text take up less because the
  expander will take up more when expanded.
</div>
<details class="expand-list">
  <summary>click me</summary>
  <ul>
    <li>One</li>
    <li>Two</li>
    <li>Three</li>
    <li>Four</li>
    <li>Five</li>
    <li>Six</li>
    <li>Seven</li>
  </ul>
</details>
  </div>
<div class="right-panel">
<div class="image">
  <p>
    Don't let this text fool you;
  </p>
  <p>
   it's actually an image.
  </p>
</div>
<button>
  Do it
</button>
  </div>
</div>

我无法明确设置右侧内容的上边距,因为左侧内容没有设置高度。

如何让左侧内容扩展时右侧内容保持不变?最好使用纯 CSS 解决方案。

css
  • 1 个回答
  • 52 Views
Martin Hope
gregsdennis
Asked: 2024-11-11 06:03:39 +0800 CST

内容被截断时更改字体大小

  • 5

我有一个 div,它可以包含很长的文本(但并非总是如此)。要求是将文本限制为三行并用省略号截断。我已经弄清楚了这部分。

第二个要求是,当文本被截断时,我需要减小字体大小,例如减小到 16px(要求中指定了大小,而不仅仅是“更小的尺寸”)。

div {
  font-size: 20px;
  max-width: 200px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}
<div>
  This is really long text that should
  definitely wrap for three lines and
  then terminate in an ellipsis if it's
  still too long, which it definitely is.
  It also needs to be a smaller font size.
</div>
<hr/>
<div>
  This text isn't long enough so it
  should be bigger.
</div>

是否可以检测文本何时被截断?如果需要,我愿意使用 JS。

像这个和这个这样的基于宽度的解决方案对我来说不起作用,因为它们只适用于单行文本。我需要一些适用于多行截断文本的东西。

html
  • 1 个回答
  • 50 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    重新格式化数字,在固定位置插入分隔符

    • 6 个回答
  • Marko Smith

    为什么 C++20 概念会导致循环约束错误,而老式的 SFINAE 不会?

    • 2 个回答
  • Marko Smith

    VScode 自动卸载扩展的问题(Material 主题)

    • 2 个回答
  • Marko Smith

    Vue 3:创建时出错“预期标识符但发现‘导入’”[重复]

    • 1 个回答
  • Marko Smith

    具有指定基础类型但没有枚举器的“枚举类”的用途是什么?

    • 1 个回答
  • Marko Smith

    如何修复未手动导入的模块的 MODULE_NOT_FOUND 错误?

    • 6 个回答
  • Marko Smith

    `(表达式,左值) = 右值` 在 C 或 C++ 中是有效的赋值吗?为什么有些编译器会接受/拒绝它?

    • 3 个回答
  • Marko Smith

    在 C++ 中,一个不执行任何操作的空程序需要 204KB 的堆,但在 C 中则不需要

    • 1 个回答
  • Marko Smith

    PowerBI 目前与 BigQuery 不兼容:Simba 驱动程序与 Windows 更新有关

    • 2 个回答
  • Marko Smith

    AdMob:MobileAds.initialize() - 对于某些设备,“java.lang.Integer 无法转换为 java.lang.String”

    • 1 个回答
  • Martin Hope
    Fantastic Mr Fox msvc std::vector 实现中仅不接受可复制类型 2025-04-23 06:40:49 +0800 CST
  • Martin Hope
    Howard Hinnant 使用 chrono 查找下一个工作日 2025-04-21 08:30:25 +0800 CST
  • Martin Hope
    Fedor 构造函数的成员初始化程序可以包含另一个成员的初始化吗? 2025-04-15 01:01:44 +0800 CST
  • Martin Hope
    Petr Filipský 为什么 C++20 概念会导致循环约束错误,而老式的 SFINAE 不会? 2025-03-23 21:39:40 +0800 CST
  • Martin Hope
    Catskul C++20 是否进行了更改,允许从已知绑定数组“type(&)[N]”转换为未知绑定数组“type(&)[]”? 2025-03-04 06:57:53 +0800 CST
  • Martin Hope
    Stefan Pochmann 为什么 {2,3,10} 和 {x,3,10} (x=2) 的顺序不同? 2025-01-13 23:24:07 +0800 CST
  • Martin Hope
    Chad Feller 在 5.2 版中,bash 条件语句中的 [[ .. ]] 中的分号现在是可选的吗? 2024-10-21 05:50:33 +0800 CST
  • Martin Hope
    Wrench 为什么双破折号 (--) 会导致此 MariaDB 子句评估为 true? 2024-05-05 13:37:20 +0800 CST
  • Martin Hope
    Waket Zheng 为什么 `dict(id=1, **{'id': 2})` 有时会引发 `KeyError: 'id'` 而不是 TypeError? 2024-05-04 14:19:19 +0800 CST
  • Martin Hope
    user924 AdMob:MobileAds.initialize() - 对于某些设备,“java.lang.Integer 无法转换为 java.lang.String” 2024-03-20 03:12:31 +0800 CST

热门标签

python javascript c++ c# java typescript sql reactjs html

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve