gpt4 book ai didi

css - 嵌套的 DIV 不服从自动

转载 作者:太空宇宙 更新时间:2023-11-04 15:53:11 27 4
gpt4 key购买 nike

见下图。请注意左右边框未填充可用空间。这些是嵌套的 div。我如何让它服从自动?

CSS 类 MiddleLeftBorder 和 MiddleRightBorder 未按预期工作。

CSS 代码如下:

html, body
{
height: 100%;
margin: 0 0 0 0;
padding: 0 0 0 0;
}
body
{
background-color: #000000;
background-image: url('/CatwalkCloset/App_Themes/Default/Images/Background.jpg');
background-repeat: repeat;
color: #FFFFFF;
}
/* TEMPLATE */
container
{
height: auto;
margin: auto;
width: 100%;
}
div.content
{
clear: both;
height: auto;
margin: 0px auto;
text-align: center;
width: 1024px;
}
div.rows div.row
{
clear: both;
width: 1024px;
}
div.rows div.column
{
float: left;
}
div.rows div.clear-row
{
line-height: 0px;
font-size: 0px;
clear: both;
}
div.logo
{
background: url('/CatwalkCloset/App_Themes/Default/Images/Logo.jpg');
height: 150px;
width: 510px;
}
div.logoSpace
{
background-color: #000000;
}
div.menu
{
background: url('/CatwalkCloset/App_Themes/Default/Images/MenuBackground.jpg');
background-repeat: repeat;
height: 40px;
width: 1024px;
}
div.topLeftBorder
{
background: url('/CatwalkCloset/App_Themes/Default/Images/TopLeftBorder.jpg');
float: left;
height: 40px;
width: 40px;
}
div.topMiddleBorder
{
background: url('/CatwalkCloset/App_Themes/Default/Images/TopMiddleBorder.jpg');
background-repeat: repeat;
float: left;
height: 40px;
width: 944px;
}
div.topRightBorder
{
background: url('/CatwalkCloset/App_Themes/Default/Images/TopRightBorder.jpg');
float: left;
height: 40px;
width: 40px;
}
div.middleLeftBorder
{
background: url('/CatwalkCloset/App_Themes/Default/Images/MiddleLeftBorder.jpg');
background-repeat: repeat;
float: left;
height: 100%;
width: 40px;
}
div.middleContent
{
float: left;
height: 100%;
width: 944px;
}
div.middleRightBorder
{
background: url('/CatwalkCloset/App_Themes/Default/Images/MiddleRightBorder.jpg');
background-repeat: repeat;
float: left;
height: 100%;
width: 40px;
}
div.bottomLeftBorder
{
background: url('/CatwalkCloset/App_Themes/Default/Images/BottomLeftBorder.jpg');
float: left;
height: 40px;
width: 40px;
}
div.bottomMiddleBorder
{
background: url('/CatwalkCloset/App_Themes/Default/Images/BottomMiddleBorder.jpg');
background-repeat: repeat;
float: left;
height: 40px;
width: 944px;
}
div.bottomRightBorder
{
background: url('/CatwalkCloset/App_Themes/Default/Images/BottomRightBorder.jpg');
float: left;
height: 40px;
width: 40px;
}

下面的 HTML 代码使用了上面的 CSS 代码:

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>

<!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 runat="server">
<title></title>
<asp:ContentPlaceHolder id="cphMasterHead" runat="server"></asp:ContentPlaceHolder>
</head>
<body>
<form id="fMaster" runat="server">
<div id="container">
<div class="content">
<div class="rows">
<div class="row">
<div class="logo"></div>
<div class="logoSpace"></div>
<div class="clear-row">&nbsp;</div>
</div>
<div class="row">
<div class="menu"></div>
<div class="clear-row">&nbsp;</div>
</div>
<div class="row">
<div class="topLeftBorder"></div>
<div class="topMiddleBorder"></div>
<div class="topRightBorder"></div>
<div class="clear-row">&nbsp;</div>
</div>
<div class="row">
<div class="middleLeftBorder"></div>
<div class="middleContent"><asp:ContentPlaceHolder id="cphMasterBody" runat="server"></asp:ContentPlaceHolder></div>
<div class="middleRightBorder"></div>
<div class="clear-row">&nbsp;</div>
</div>
<div class="row">
<div class="bottomLeftBorder"></div>
<div class="bottomMiddleBorder"></div>
<div class="bottomRightBorder"></div>
<div class="clear-row">&nbsp;</div>
</div>
</div>
</div>
</div>
</form>
</body>
</html>

最佳答案

为什么要使用图像来完成纯 CSS (border-radius) 可以完成的事情?我指的是 #content 中的那个框架。但是好吧..

首先确保图像在您编写的路径中(使用 F12 和网络选项卡查看是否没有任何错误),因为 CSS 类和 HTML 标记看起来是正确的。不是,只是正确

由于您为 .row.middleContent.middleLeftBorder.middleRightBorder 使用了固定宽度,因此有无需使用 3 张图像来构建您的背景 - 您可以将它们合并为 .row 的一个背景。当你在 .row

中有 clear: both; 时,也不需要使用 div.clear-row

我认为这里有太多需要改进的地方..


好的,关于圆 Angular 。您可以使用这段代码(与您的代码松散相关)实现我认为您想要的东西:

<div id="container">
<div id="content">Some text here</div>
</div>

<style>
#container {
width: 200px;
padding: 15px;
background-color: #000;
}
#content {
padding: 30px; /* real content must be moved away from border */
border: 1px solid #fff;
color: #fff;
width: 138px; /* #container width - 2*padding - 2*border */
border-radius: 20px; /* Basic CSS */
-moz-border-radius: 20px; /* Mozilla */
-webkit-border-radius: 20px; /* Safari, Chrome */
-o-border-radius: 20px; /* Opera */
-ms-border-radius: 20px; /* IE9+ */
}
</style>

你应该得到黑色背景上带有圆 Angular 的白色矩形。

关于css - 嵌套的 DIV 不服从自动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10904684/

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