html - 带有扩展水平背景的左侧边栏?

标签 html css response

是否可以有一个侧边栏仅通过背景图像/颜色连接到浏览器的左侧,但是,无论浏览器的大小如何,其中的内容都保持在右侧并且与其他内容的距离相同并且两者内容 block 居中?

Like this image explains..

我想也许是百分比,但它与导致问题的右侧列的关系..

最佳答案

您可以使用长边框和负边距来实现这一点。

http://jsfiddle.net/davidja/TWdXe/2/

.outer {
    height:200px;
    position:relative;
    width:650px;       // make your fixed container
    margin-left:auto;  // center it
    margin-right:auto; // center it
}
.inner {
    height:200px;
    background:red;
    width:200px;
    display:inline-block;
    border-left: solid 1000px red; // long border on the left  
     margin-left: -1000px;         // negative margin to keep the layout 
}
.foo {
    width:400px;
    background:orange;
    display:inline-block;
    border-right: solid 1000px orange; // long border on the right - optional
    margin-right: -1000px;             // negative margin to keep the layout -  optional 
}


body {overflow:hidden;}  //Resolves horizontal scrollbar

关于html - 带有扩展水平背景的左侧边栏?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17339698/

相关文章:

javascript - 单击时删除输入文本的默认值

html - 为什么我的页面让我在移动设备上滚动两次?

html - 如何更改非事件颜色选项卡 Bootstrap

http - 同时具有 gzip 和 Etag 时无法缓存资源

node.js - 如何将 axios 响应保存到变量,以便在 axios 外部使用?

javascript - 检查youtube视频id是否存在Javascript

javascript - 如何在现有选项卡中引入内容

css - 为什么 <li> 标签放错地方了?

php - PHP 中的 HTML 样式不遵循 CSS

html - 3张图片作为div的背景