gpt4 book ai didi

html - 内容和侧边栏需要扩展背景,同时保持网格对齐

转载 作者:行者123 更新时间:2023-11-28 16:30:41 25 4
gpt4 key购买 nike

我有一个内容边栏布局。内容有一种背景颜色,而侧边栏有另一种背景颜色,非常简单。您将在附加源代码的 .centered-example elements 分支中看到此配置。

我面临的问题不仅是模仿 .centered-example 的居中内容网格,而且是“扩展”.content。 sidebar 背景到视口(viewport)的边缘(如 .wrap-left.wrap-right 元素所示)并使其(大部分)保持响应。

这是成品的示例: Finished Product Example

代码如下:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<style>
.wrap-left{
width:66%;
min-height:500px;
display:inline-block;
float:left;
background-color:rgba(0,0,0,0.48);
}
.wrap-right{
width:34%;
background-color:rgba(172, 172, 172, 0.48);
min-height:500px;
display:inline-block;
float:left;
}
.wrap-left .content{
max-width:693px;
width:100%;
height:100%;
float:right;
background-color:transparent;
/*background-color:rgba(0,0,0,0.48);*/
}
.wrap-right .sidebar{
max-width:347px;
width:100%;
height:100%;
float:left;
background-color:transparent;
/*background-color:rgba(172, 172, 172, 0.48);*/
}
.centered-example{
width:100%;
max-width:1040px;
height:200px;
background-color:#000000;
margin:0 auto;
clear:both;
}
.centered-example .content{
width:66%;
height:100%;
float:left;
background-color:rgba(0,0,0,0.48);
}
.centered-example .sidebar{
width:34%;
height:100%;
float:left;
background-color:rgba(172, 172, 172, 0.48);
}
</style>
</head>
<body>
<div class="wrap-left">
<div class="content">
This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.
</div>
</div>
<div class="wrap-right">
<div class="sidebar">
This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.
</div>
</div>
<div class="centered-example">
<div class="content"></div>
<div class="sidebar"></div>
</div>
</body>
</html>

您可以在此处查看实际示例:https://jsfiddle.net/fc1Lxmhs/

如果需要更多说明,请告诉我。类似执行的任何站点示例也很有帮助。

最佳答案

您可以在包含元素(在本例中为主体)上使用 CSS3 渐变伪造扩展背景。

* {
margin: 0;
padding: 0;
}

body {
background: -webkit-gradient(linear, 100% 50%, 0% 50%, color-stop(50%, #D7D7D7), color-stop(50%, #858585));
background: -webkit-linear-gradient(right, #D7D7D7 50%, #858585 50%);
background: -moz-linear-gradient(right, #D7D7D7 50%, #858585 50%);
background: -o-linear-gradient(right, #D7D7D7 50%, #858585 50%);
background: linear-gradient(right, #D7D7D7 50%, #858585 50%);
}

.wrapper {
width: 1040px;
min-height: 700px;
margin: 0 auto;
overflow: hidden;
}

.content {
width: 66%;
float: left;
min-height: 700px;
background: #858585;
}

.sidebar {
width: 34%;
float: right;
min-height: 700px;
background: #D7D7D7;
}
<body>
<div class="wrapper">
<div class="content">
This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.This is the content.
</div>
<div class="sidebar">
This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.This is the sidebar.
</div>
</div>
</body>

关于html - 内容和侧边栏需要扩展背景,同时保持网格对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35372453/

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