如何使用 css 设计仅由 div 组成的 xhtml 标记(如表格)

发布于 2024-08-14 01:26:53 字数 2717 浏览 2 评论 0 原文

请参阅此 http://jsbin.com/iveso 的源代码 我无法更改 xhtml 代码中的任何内容。

我需要像这样的跨浏览器输出。 替代文本 http://easycaptures.com/fs/uploaded/445/5025516010.jpg< /a>

我们如何用更少的资源提供相同的外观并优化 css

这是 CSS

#ConferencesContainer {
  overflow: hidden;
}

#ConferencesContainer img {
  float: left;
  padding: 0 10px 10px 0;
}

#ConferencesContainer #ConferencesItemsContainer img {
  float: none;
  padding: 0;
}

#ConferencesHeaderContainer {
  font-size: 1.1em;
  font-weight: bold;
  margin: 10px 0;
  overflow: hidden;
}

#ConferencesTitleHeaderContainer {
  float: left;
  width: 40%;
}

#ConferencesPDFHeaderContainer {
  float: left;
  text-align: center;
  width: 20%;
}

#ConferencesExternalLinkHeaderContainer {
  float: left;
  text-align: center;
  width: 20%;
}

#ConferencesHtmlHeaderContainer {
  float: left;
  text-align: center;
  width: 20%;
}

.Conferencesnorth-america-2009ItemContainer {
  border-bottom: 1px solid #008999;
  overflow: hidden;
  padding: 5px 0;
  position: relative;
}

.Conferencesaustralia-and-asia-2008ItemContainer {
  border-bottom: 1px solid #008999;
  overflow: hidden;
  padding: 5px 0;
  position: relative;
}

.Conferencesinvestor-conference-2008ItemContainer {
  border-bottom: 1px solid #008999;
  overflow: hidden;
  padding: 5px 0;
  position: relative;
}

#ConferencesContainer .ConferencesTitleContainer {
  float: left;
  padding: 2px 0;
  width: 40%;
}

#ConferencesContainer .ConferencesPdfContainer {
  float: left;
  left: 40%;
  position: absolute;
  text-align: center;
  width: 20%;
}

#ConferencesContainer .ConferencesExtLinkContainer {
  float: left;
  left: 60%;
  position: absolute;
  text-align: center;
  width: 20%;
}

#ConferencesContainer .ConferencesHtmlContainer {
  float: left;
  left: 80%;
  position: absolute;
  text-align: center;
  width: 20%;
}

#ConferencesAcrobatWarningContainer {
  float: left;
  padding-top: 20px;
}

.Conferencesaustralia-and-asia-2008ItemContainer #ConferencesasiaTitleContainer {
  font-weight: bold;
}

.Conferencesaustralia-and-asia-2008ItemContainer #ConferencesaustraliaTitleContainer {
  font-weight: bold;
}

编辑:

我找到了对我有用的链接

  1. http://snook.ca/archives/html_and_css/getting_your_di

  2. http://www.dev-archive.net/articles/table-in-css。 html

See source code of this http://jsbin.com/iveso I can't change anything in xhtml code.

And i need cross browser output exact like this.
alt text http://easycaptures.com/fs/uploaded/445/5025516010.jpg

How we can give same look with less and optimize css

This is CSS

#ConferencesContainer {
  overflow: hidden;
}

#ConferencesContainer img {
  float: left;
  padding: 0 10px 10px 0;
}

#ConferencesContainer #ConferencesItemsContainer img {
  float: none;
  padding: 0;
}

#ConferencesHeaderContainer {
  font-size: 1.1em;
  font-weight: bold;
  margin: 10px 0;
  overflow: hidden;
}

#ConferencesTitleHeaderContainer {
  float: left;
  width: 40%;
}

#ConferencesPDFHeaderContainer {
  float: left;
  text-align: center;
  width: 20%;
}

#ConferencesExternalLinkHeaderContainer {
  float: left;
  text-align: center;
  width: 20%;
}

#ConferencesHtmlHeaderContainer {
  float: left;
  text-align: center;
  width: 20%;
}

.Conferencesnorth-america-2009ItemContainer {
  border-bottom: 1px solid #008999;
  overflow: hidden;
  padding: 5px 0;
  position: relative;
}

.Conferencesaustralia-and-asia-2008ItemContainer {
  border-bottom: 1px solid #008999;
  overflow: hidden;
  padding: 5px 0;
  position: relative;
}

.Conferencesinvestor-conference-2008ItemContainer {
  border-bottom: 1px solid #008999;
  overflow: hidden;
  padding: 5px 0;
  position: relative;
}

#ConferencesContainer .ConferencesTitleContainer {
  float: left;
  padding: 2px 0;
  width: 40%;
}

#ConferencesContainer .ConferencesPdfContainer {
  float: left;
  left: 40%;
  position: absolute;
  text-align: center;
  width: 20%;
}

#ConferencesContainer .ConferencesExtLinkContainer {
  float: left;
  left: 60%;
  position: absolute;
  text-align: center;
  width: 20%;
}

#ConferencesContainer .ConferencesHtmlContainer {
  float: left;
  left: 80%;
  position: absolute;
  text-align: center;
  width: 20%;
}

#ConferencesAcrobatWarningContainer {
  float: left;
  padding-top: 20px;
}

.Conferencesaustralia-and-asia-2008ItemContainer #ConferencesasiaTitleContainer {
  font-weight: bold;
}

.Conferencesaustralia-and-asia-2008ItemContainer #ConferencesaustraliaTitleContainer {
  font-weight: bold;
}

Edit:

I found links which are useful for me

  1. http://snook.ca/archives/html_and_css/getting_your_di

  2. http://www.dev-archive.net/articles/table-in-css.html

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

离去的眼神 2024-08-21 01:26:53

“授人以鱼,可喂一日;授人以鱼,可终身受用”

好吧,我们开始吧。如果首先安装 Firefox 以便我可以使用 Firebug 扩展。

因此,您显然无法控制仅由 div 组成的标记。到目前为止,一切都很好。

我通过删除 #ConferencesContainer 更改了您的 css 片段,因为 Firebug 显然表明您的标记中无论如何都没有带有 id ConferencesContainerdiv ...这解释了为什么 #ConferencesContainer .ConferencesTitleContainer { 等不选择任何内容。

然后我删除了绝对定位,因为据我所知,这在 IE 中表现不佳。顺便说一句,如果您随后使用 position:absolute ,则 float: left 是没有用的。

为了适应有时没有 pdf 下载链接的事实(因此没有 div 在标记中),我将议程项目和 pdf 链接 div 浮动到左侧。我将传记和网络广播 div 浮动 到右侧,并欺骗边距将 div 切换回其预期位置。欺骗边距是必要的,因为网络广播 div 在标记中排在第一位(相对于传记 div)。

当然,如果您应用我给您的样式表,使用带有“漏洞”的稍微不同的标记,也就是说缺少 div,因为没有相应的输出链接,那么它可能无法工作。

无论如何,我相信你现在已经有足够的东西可以自己尝试了,祝你好运。

.ConferencesTitleContainer {
float:left;
padding:2px 0;
width:40%;
background: red;
}
.ConferencesPdfContainer {
float:left;
text-align:center;
width:20%;
background: yellow;
}
.ConferencesExtLinkContainer {
float:right;
margin-left: -20%;
margin-right: 20%;
text-align:center;
width:20%;
background: lime;
}
.ConferencesHtmlContainer {
float: right;
margin-left: 20%;
margin-right: -20%;
text-align:center;
width:20%;
background: pink;
}

替代文本
(来源:pakosz.fr

查看实际操作。

而且,您可能想阅读十大 CSS 表格设计10 个 CSS 表格示例用于漂亮的样式。

PS:编码器颜色是为了帮助可视化 div。

"Give a man a fish, and you feed him for a day, teach him to fish, and you feed him for a lifetime"

Ok here we go. If started by installing Firefox so that I can use the Firebug extension.

So you apparently have no control over the the markup which is only made of divs. So far so good.

I changed a fragment of your css by removing #ConferencesContainer as Firebug obviously shows you that there is no div with the id ConferencesContainer in your markup anyway... Which explains why #ConferencesContainer .ConferencesTitleContainer { and alike select nothing.

Then I removed the absolute positioning because as far as I can recall, this is something that doesn't play nice with IE. By the way, having float: left is useless if you then use position: absolute

To accommodate the fact that sometimes there is no pdf download link (hence no div in the markup), I made agenda item and pdf link divs float to the left. And I made biography and webcast divs float to the right and tricked the margins to switch the divs back to their intended position. Tricking the margins was necessary as the webcast div comes first in the markup (in respect to the biography div).

Of course, if you apply the stylesheet I'm giving you to a slightly different markup with "holes", that is to say missing divs because there is no corresponding link to output then it might not work.

In any case, I believe you now have enough to experiment with on your own, good luck.

.ConferencesTitleContainer {
float:left;
padding:2px 0;
width:40%;
background: red;
}
.ConferencesPdfContainer {
float:left;
text-align:center;
width:20%;
background: yellow;
}
.ConferencesExtLinkContainer {
float:right;
margin-left: -20%;
margin-right: 20%;
text-align:center;
width:20%;
background: lime;
}
.ConferencesHtmlContainer {
float: right;
margin-left: 20%;
margin-right: -20%;
text-align:center;
width:20%;
background: pink;
}

alt text
(source: pakosz.fr)

See it in action.

And, you might want to read Top 10 CSS Table Designs or 10 CSS Table Examples for pretty styling.

PS: the coder colors are here to help visualizing divs.

感性不性感 2024-08-21 01:26:53

我想,你必须玩一点。此外,您肯定需要一些图像,并对 xhtml 代码有很大的耐心,尤其是出色的 id 和 id 。类名。

以下是可以帮助您入门的内容:

.ConferencesTitleContainer, .ConferencesPdfContainer, .ConferencesExtLinkContainer, .ConferencesHtmlContainer, .ConferencesTitleHeaderContainer, .ConferencesPDFHeaderContainer, .ConferencesExternalLinkHeaderContainer, .ConferencesHtmlHeaderContainer {
float:left;
width:24%;
border-bottom:1px solid;
}
#ConferencesasiaTitleContainer, #ConferencesaustraliaTitleContainer {
width:96%;
font-weight:bold;
}

I think, you have to play with a bit . Furthermore, you definitely need some images and a lot of patience with the xhtml code and especially the great id & class names.

Here is something that can get you started:

.ConferencesTitleContainer, .ConferencesPdfContainer, .ConferencesExtLinkContainer, .ConferencesHtmlContainer, .ConferencesTitleHeaderContainer, .ConferencesPDFHeaderContainer, .ConferencesExternalLinkHeaderContainer, .ConferencesHtmlHeaderContainer {
float:left;
width:24%;
border-bottom:1px solid;
}
#ConferencesasiaTitleContainer, #ConferencesaustraliaTitleContainer {
width:96%;
font-weight:bold;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文