gpt4 book ai didi

html - CSS 格式保持一致

转载 作者:太空狗 更新时间:2023-10-29 14:40:10 25 4
gpt4 key购买 nike

花了很多时间来正确设置此格式,因此我们将不胜感激。我们有一堆关于 foos 的信息,我们希望将它们组合在一起。因此,如果我们有一堆 foos 并排列出,如果该元素导致 foos 换行,则整个 foo 将保持在一起.格式也应如下所示:所以文本在左边,数字在右边。

|-----------------------------------------------------|
|[icon] Brad (human) [pic] (2) [pic] (3)|
|-----------------------------------------------------|

所以主图标在最左边,然后是名称和型号,然后右对齐的是 siblings 和 kids(每个图标都有 css 嵌入式图标)。

每个 foo 可以有以下内容:

foo.id = 12345
foo.name = 'brad'
foo.model = 'human'
foo.image = ''
foo.kids = 3
foo.siblings = 2
foo.link = ''

-

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>none</title>
<style type="text/css" >

body
{
margin: 0;
padding: 0;
min-width: 850px;
text-align: left;
line-height: 28px;
font-size: 14px;
font-family: Verdana,Tahoma,Arial;
}

#content
{
width: 800px;
border: solid 1px #000000;
margin-top: 20px;
margin-left: auto;
margin-right: auto;
}

div.foo
{
display: inline;
min-width: 250px;
width: 250px;
border: dotted 1px #b8b8b8;
padding: 0px 15px 0px 0px;
vertical-align: middle;
}

.foo .id
{
display: none;
}

.foodata
{
display: inline;
text-align: left;
white-space: nowrap;
margin: 2px 2px 2px 2px;
}


.fooname
{
display: inline;
min-width: 80px;
font-weight: bold;
font-size: 12px;
white-space: nowrap;
}

.foomodel
{
display: inline;
min-width: 80px;
color: #000000;
font-size: 12px;
}

.foocounts
{
min-width: 90px;
text-align: right;
display: inline;
}

.foosiblings
{ /* add in image for children */
background: url(../../images/siblings.png) no-repeat 4px 10%;
text-align: right;
font-size: 12px;
min-width: 50px;
display: inline;
}

.fookids
{ /* add in image for connection */
background: url(../../images/kids.png) no-repeat 4px 25%;
text-align: right;
font-size: 12px;
min-width: 50px;
display: inline;
}

.fooimage
{
display: inline;
vertical-align: middle;
}

</style>
</head>
<body>

<div id="content" >
<div class="foo" >
<span class="id" >12345</span>
<a href="" class="foolink" >
<img src="" alt="XX" class="fooimage" height="16" width="16" />
<span class="foodata" >
<span class="fooname" >Brad</span>
<span class="foomodel" >(human)</span>
</span>
<span class="foocounts" >
<span class="foosiblings" >(3)</span>
<span class="fookids" >(2)</span>
</span>
</a>
</div>

<div class="foo" >
<span class="id" >12345</span>
<a href="" class="foolink" >
<img src="" alt="XX" class="fooimage" height="16" width="16" />
<span class="foodata" >
<span class="fooname" >Tom</span>
<span class="foomodel" >(human)</span>
</span>
<span class="foocounts" >
<span class="fookids" >(1)</span>
</span>
</a>
</div>

<div class="foo" >
<span class="id" >12345</span>
<a href="" class="foolink" >
<img src="" alt="XX" class="fooimage" height="16" width="16" />
<span class="foodata" >
<span class="fooname" >Harry</span>
<span class="foomodel" >(human)</span>
</span>
<span class="foocounts" >
<span class="foosiblings" >(6)</span>
</span>
</a>
</div>

<div class="foo" >
<span class="id" >12345</span>
<a href="" class="foolink" >
<img src="" alt="XX" class="fooimage" height="16" width="16" />
<span class="foodata" >
<span class="fooname" >Sally</span>
<span class="foomodel" >(human)</span>
</span>
<span class="foocounts" >
</span>
</a>
</div>

<div class="foo" >
<span class="id" >12345</span>
<a href="" class="foolink" >
<img src="" alt="XX" class="fooimage" height="16" width="16" />
<span class="foodata" >
<span class="fooname" >Peggy</span>
<span class="foomodel" >(human)</span>
</span>
<span class="foocounts" >
<span class="fookids" >(12)</span>
<span class="foosiblings" >(16)</span>
</span>
</a>
</div>
</div>

</body>
</html>

重要的是我想将整个 foo 放在一起,放在一个大块中,因为我在整个页面上都使用了这个结构。如果需要,foo 的结构可以更改,我可以完全控制它。

最佳答案

white-space:nowrap 样式确实可以防止“foo”div 损坏,但我也发现它会导致它们超出“content”div 中定义的宽度。

我发现以下内容适用于 IE、Firefox 和 Chrome(仅限 pc,目前无法访问 Mac)

div.foo
{
display:inline-block;
}

关于html - CSS 格式保持一致,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1910217/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com