CSS Firefox扩展父div,但不是IE或Chrome,错误? [英] CSS Firefox expands parent div but not IE or Chrome, bug?

查看:165
本文介绍了CSS Firefox扩展父div,但不是IE或Chrome,错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想做一个博客时尚的设计,在父亲的div左边有一个日期块。它适用于IE和Chrome,但在Firefox中,顶层父div扩展。

I'm trying to do a blog stylish design with a "date block" to the left of parenting div. It works in IE and Chrome but in Firefox the top-parent div expands.

html

    <div class="post_bg">
        <div class="post_inner">
            <div class="blue">date</div>
            text
            <br /><br />
        </div>
    </div>

Css

.post_bg {
  width: 700px;
  background-color: #f0f0f0;
  outline: 1px solid #d8d8d8;
  border-top: 1px solid #fff;
  padding: 5px 5px 5px 5px;
}
.post_inner {
  clear: both;
  background-color: #fdfdfd;
  border: 1px solid #d8d8d8;
}
.blue {
  overflow: visible;
  width: 40px;
  height: 40px;
  background-color: #55a4cc;
  position: relative;
  bottom: -5px;
  right: 40px;
}

这是一张显示我问题的图片:

Here is a picture showing my problem:

推荐答案

要获得大纲在Firefox中工作替换:

To get the outline to work in Firefox replace:

outline: 1px solid #d8d8d8;

有:

box-shadow: 0 0 0 1px #d8d8d8;

要使文本与顶部对齐,请使 .post_inner position:relative; .blue position:absolute; 。然后调整 .blue 的位置。

To get the text aligned to the top make .post_inner position: relative; and .blue position: absolute;. Then adjust .blue's position accordingly.

演示: http://jsfiddle.net/ThinkingStiff/8SyGV/

CSS:

.post_bg {
    background-color: #f0f0f0;
    border-top: 1px solid #fff;
    left: 40px;
    box-shadow: 0 0 0 1px #d8d8d8;
    padding: 5px 5px 5px 5px;
    position: relative;
    width: 300px;
}
.post_inner {
    background-color: #fdfdfd;
    border: 1px solid #d8d8d8;
    position: relative;
}
.blue {
    background-color: #55a4cc;
    height: 40px;
    left: -40px;
    position: absolute;
    top: 0;
    width: 40px;
}

HTML:

<div class="post_bg">
    <div class="post_inner">
        <div class="blue">date</div>
        text
        <br /><br />
    </div>
</div>

这篇关于CSS Firefox扩展父div,但不是IE或Chrome,错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆