CSS 浮动第三个元素,其内容取决于宽度
我正在为他们动态添加的一家餐厅制作菜单。看起来像这样
Dish Name Price
Content in the dish,Content in the dish,Content in the dish,
Content in the dish,Content in the dish.
我想要做的是用 来点缀空白区域。或虚线边框。 但我不知道如何让 css 自动调整空白 div 的宽度。 菜名可以比“菜名”更长。 Any1对此有解决方案吗?
编辑 价格和名称位于 2 个 div 中,上面已经有浮动了
.dishHead
{
font-family:Verdana;
font-size: 18px;
color:#262626;
float:left;
font-weight:200;
}
.dishPrice
{
font-family:Verdana;
font-size: 14px;
color:#262626;
float:right;
}
Edit2: 整个结构如下:
一个向右或向左浮动的div 左边的浮动头,右边的浮动价格,以及下面的说明。 我需要在 head 和 Price 之间有一个 div,而不影响它所在的整个 div
I'm doing a menu for a restaurant that they dynamiclly add. it looks like this
Dish Name Price
Content in the dish,Content in the dish,Content in the dish,
Content in the dish,Content in the dish.
What i want to do is to get the blank space dotted, with . or dotted border.
But i cannot figure out how to get the css to autoadjust the width of the blank space div.
The dishnames could be longer then "dishname".
Any1 have a solution for this?
EDIT
The price and name is in 2 divs already with floats on them
.dishHead
{
font-family:Verdana;
font-size: 18px;
color:#262626;
float:left;
font-weight:200;
}
.dishPrice
{
font-family:Verdana;
font-size: 14px;
color:#262626;
float:right;
}
Edit2:
The whole thing is structured as below:
a div that floats right or left
the left floating head, the right floating price, and a description below.
I need a div between the head and price without affecting the whole div it lies in
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我想我会在整个“标题”部分使用背景图像,然后在名称和价格 div 上使用背景颜色来覆盖图像,但这只有在背景是纯色时才有效。
为了回答您的问题,让第三个 div 占据左右 div 之间的剩余空间,您将在其上使用
overflow:hidden
,因此使用虚线边框的示例可能如下所示:< a href="http://jsfiddle.net/clairesuzy/Q6WAx/" rel="nofollow noreferrer">示例 Fiddle
CSS:
HTML:
I think I would do it with a background image on the whole of the "heading" part then use a background color on the name and price div to cover the image however that will only work if the background is a plain colour.
In answer to your question to get a third div to take up the remaining space between the left and right divs you would use
overflow:hidden
on it so an example using a dotted border might look like this:Example Fiddle
CSS:
HTML:
您可以在带有菜肴名称的元素中放置很多点,并使用以下 css:
You could place lots of dots in an element with dishname and use the fallowing css: