css - css - 如何内联显示信息块
问题描述
不知道为什么我自己搞不定这个,因为感觉比较简单,我想内联显示两个“块”。我想要的结果可以在下面的超链接中找到(转到图像)
我拥有的html是
#content-main {
float: right;
}
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<link href="css/main.css" rel="stylesheet" type="text/css">
<title>challenge 5</title>
</head>
<body>
<div id="header">
<blockquote>
<p>Learning is not a privilege, it's a right.</p>
</blockquote>
<div id="logo">
<h1>live and let learn</h1>
<img src="img/Csschallenge5.jpg" alt="live and let learn">
</div>
</div>
<div id="content">
<div id="content-side">
<dl>
<dt><a href="services/">Services</a></dt>
<dd>Learning and facilitation through TAFE WSI</dd>
<dt><a href="learning/">Personal Learning</a></dt>
<dd>Learning from the network</dd>
<dt><a href="resources/">Resources</a></dt>
<dd>Browse through resources ...</dd>
<dt><a href="about/">About</a></dt>
<dd>What am I about? Personal interests and other stuff</dd>
</dl>
</div>
<!-- content-side -->
<div id="content-main">
<h2>Please update your links!</h2>
<small>Wednesday, October 12th, 2005</small>
<p>New blog address: <a href="http://liveandletlearn.net/learning/">
http://liveandletlearn.net/learning/</a>
</p>
<p>During the last holidays I've been busy moving my blog from
<a href="http://www.absoludity.net/blog/">absoludity.net</a> to
<a href="http://liveandletlearn.net/learning/">liveandletlearn.net</a> ... why? Good question! Part of the Web Design course that I facilitate is a client project where participants are required to develop a site from start to finish - and i'd
been a while since I'd been through that process myself - so what better a project for the holidays (next to my gardening project to get me <em>away</em> from the computer)!
</p>
<p>You'll notice that the site itself is still in prototype stage, but the blog is all up and running so I'm going to be using liveandletlearn from now on. <strong>Please update your
bookmarks/feeds</strong>! And please give me any feedback you've got time for at
<a href="http://liveandletlearn.net/learning/">liveandletlearn.net</a>!
</p>
</div>
<!-- content-main -->
</div>
<!-- content -->
</body>
</html>
我没有太多的 CSS,因为我不知道从哪里开始,这就是我所拥有的:
#content-main {
float: right;
}
我被告知使用display: inline;
或float: right;
它做了一些事情,但不是我想要实现的,我正在努力实现这一目标。网站布局/示例
我试过研究它无济于事。我已经有一段时间没有使用 css 了,所以请原谅我的生疏。
解决方案
使用 CSS flexbox 布局。为 content-side 和 content-main 添加 flex 属性。flex 是 flex-grow、flex-shrink 和 flex-basis 的简写。
以下是您可以尝试的css。
#content {
display:flex;
}
#content-side {
flex: 0 0 25%;
}
#content-main {
flex: 1;
}
推荐阅读
- ruby - 使用 Adobe PKCS#7 证书在 Origami 中签名的 PDF 验证
- if-statement - 如何仅在页面及其子页面上显示部分内容?十月CMS
- testing - 拖动点不起作用并且不会引发错误
- c++ - 读取 USB 和操作系统之间传输的数据,C++
- excel - 从工作表中删除大量行时窒息
- xml - 用于定义最小元素集的 XML 模式
- node.js - 如何检查套接字是否已发出
- asp.net-core - EF Core 3 x.where 扩展方法返回 IEnumerable 而不是 IQueryable
- javascript - 如何传递数字 id 而不是字符串 id?
- python - 在 Python 中定义函数后如何更改函数范围内的变量?