Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html CSS:如何定义具有无限垂直边框和100%初始高度的居中div?_Html_Css_Height_Border - Fatal编程技术网

Html CSS:如何定义具有无限垂直边框和100%初始高度的居中div?

Html CSS:如何定义具有无限垂直边框和100%初始高度的居中div?,html,css,height,border,Html,Css,Height,Border,关于SOF的第一个问题,如果这可能是一个愚蠢的问题,请温和一些 无论是在这里还是在网上,都没有找到解决方案 我在CSS方面遇到了一些麻烦。我在这篇文章的末尾粘贴了我的代码,但首先我将解释我试图实现的目标: 我想构建一个中心固定宽度的内容区域,其左右两侧有无尽的垂直图形边框。 这就是我所尝试的: 我创建了一个包含.wrapper div的#content div。将分区Id设置为中心的标准程序。将左边框的background属性赋予#content,将右背景赋予.wrapper div。 #内容很

关于SOF的第一个问题,如果这可能是一个愚蠢的问题,请温和一些 无论是在这里还是在网上,都没有找到解决方案

我在CSS方面遇到了一些麻烦。我在这篇文章的末尾粘贴了我的代码,但首先我将解释我试图实现的目标:

我想构建一个中心固定宽度的内容区域,其左右两侧有无尽的垂直图形边框。

这就是我所尝试的:

  • 我创建了一个包含.wrapper div的#content div。将分区Id设置为中心的标准程序。将左边框的background属性赋予#content,将右背景赋予.wrapper div。 #内容很好:无尽的左边框。 但是.wrapper与它的内容保持相同的高度。因此,如果内容较少,那么浏览器的高度和边框将不会是无限的

  • 如果我将内容高度设置为100%,边框将一直显示到页面底部,但是如果内容高于浏览器高度,并且我向下滚动,边框将不会继续

  • 我在#content和.wrapper之间插入了另一个div:#contentbr,并为该div赋予了与#content相同的属性,但带有右边框的图形:不起作用,高度与包装的内容相同

  • 尝试了一些小的调整,但都没有达到我想要的效果

    可悲的是:如果我将#content的background属性设置为以下值,Nr.2就可以正常工作: _背景:url(img/content\u left.png)左上重复-y,url(img/content\u left.png)右上重复-y_

    不幸的是,IE不知道CSS 3,所以这不是解决方案,因为我不能忽略IE…:(

    所以我希望能得到你们的一些帮助。有人必须知道如何做这个魔术


    关于我的HTML和CSS示例的重要注意事项: 我将背景属性替换为边框属性。实际上,左边框和右边框需要是两个不同的图像,并使用已注释的背景属性!

    HTML和CSS:

    <!doctype html>
    <html>
    <head>
        <!-- <link rel="stylesheet" type="text/css" href="css/style.css"> -->
        <style type="text/css">
            html, body { height: 100%; }
    
            #content 
            {
                margin: 0 auto;
                width: 950px;
    
                /* this is the real deal: */
                /* background: url("img/content_left.png") top left repeat-y; */
    
                /* this is just for the example */
                border-left: 1px solid black;
    
                height: auto !important;
                height: 100%; /* IE 6 Workaround */
                min-height: 100%;
            }
    
            #content .wrapper
            {
                /* this is the real deal: */
                /* background: url("img/content_right.png") top right repeat-y; */
    
                /* this is just for the example */
                border-right: 1px solid black;
    
                height: auto !important;
                height: 100%; /* IE 6 Workaround */
                min-height: 100%;
    
                padding: 0px 70px;
            }
        </style>
    </head>
    <body>
        <div id="content">
            <div class="wrapper">
                <p>
                    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed malesuada, lorem ut lobortis congue, ligula risus condimentum enim, 
                    vel ornare mi elit et purus. Duis justo libero, posuere nec ullamcorper nec, tempus nec augue. Maecenas rhoncus, sapien a dapibus 
                    accumsan, nisl mi gravida arcu, id congue neque nisi vitae lacus. Morbi dapibus mollis tempor. Praesent tortor ipsum, rhoncus in 
                    rhoncus sit amet, luctus nec nibh. Donec enim massa, fermentum et consectetur et, iaculis nec tortor. Mauris massa elit, pellentesque 
                    id vestibulum in, vehicula nec elit. In congue purus vitae mauris adipiscing a sollicitudin dolor consectetur. In lacus lectus, 
                    auctor nec facilisis non, tempus ut neque. Sed id elit vel dui porta condimentum vitae ac lorem. Nam suscipit elit ac est sollicitudin 
                    sed faucibus tellus aliquam. Sed quis libero odio, pellentesque fermentum odio. Aliquam hendrerit dignissim sapien a vestibulum. 
                    Phasellus aliquam pretium erat eu feugiat. Quisque enim arcu, sagittis at venenatis quis, auctor vitae diam. Donec sed arcu sapien. 
                    Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Nulla eget lacus id enim pulvinar ullamcorper.
                </p>
        </div>
        </div>
    </body>
    </html>
    
    
    html,正文{高度:100%;}
    #内容
    {
    保证金:0自动;
    宽度:950px;
    /*这才是真正的交易:*/
    /*背景:url(“img/content_left.png”)左上角的repeat-y*/
    /*这只是一个例子*/
    左边框:1px纯黑;
    高度:自动!重要;
    高度:100%;/*IE 6解决方案*/
    最小高度:100%;
    }
    #内容包装器
    {
    /*这才是真正的交易:*/
    /*背景:url(“img/content\u right.png”)右上角重复-y*/
    /*这只是一个例子*/
    右边框:1px纯黑;
    高度:自动!重要;
    高度:100%;/*IE 6解决方案*/
    最小高度:100%;
    填充:0px 70px;
    }
    
    Lorem ipsum dolor sit amet,圣公会精英。Sed malesuada,Lorem ut lobortis congue,ligula risus调味品,
    我是精英和普通人。我是自由人,我是自由人,我是自由人,我是自由人,我是奥古斯人。我是朗卡斯人,我是达皮布斯人
    累及性,我是孕妇,我是老年痴呆症患者。暂时性莫氏症。前斜颈,后斜颈
    朗卡斯·塞特·阿梅特、卢克图斯·奈克·尼伯、多奈克·埃尼姆·马萨、发酵剂和连续发酵剂、艾库利斯·奈克·托托、莫里斯·马萨·艾利特、佩伦茨克
    我的前庭在,交通工具在茅草丛中,我的前庭在黑暗中,我的前庭在黑暗中,我的前庭,我的前庭,我的前庭,我的前庭,我的前庭,我的前庭,我的前庭,我的前庭,我的前庭,我的前庭,我的前庭,我的前庭,
    拍卖人nec facilisis non,tempus ut neque.他是一名精英,在调味品中获得了丰富的知识,而不是一名精英
    这句话的意思是:阿利奎姆·福西布斯·泰卢斯·阿利奎姆·阿利奎姆·阿利奎姆·亨德雷特·萨皮恩·阿利奎姆·阿利奎姆·阿利奎姆·阿利奎姆·阿利奎姆·阿利奎姆·阿利奎姆·阿利奎姆·亨德雷特·萨皮恩·阿利奥。
    在欧盟封建主义者之前的一段时间里,维特纳提斯的萨吉提斯,维塔·迪亚姆·多内克·塞德·萨吉安的拍卖师。
    每一个康努比亚人,每一个希梅纳奥斯人,都有一个社会性的自由和自由的权利。这是一个公共的自由。
    

    据我所知,min height hack要求您按以下顺序放置属性:

    min-height: 100%; height: auto !important; height: 100%; 最小高度:100%; 高度:自动!重要; 身高:100%; 也许我错了,但我确信这是唯一的解决办法

    如果你在页面中央有一个100%高的div,为什么不创建一个可以应用于主体的重复背景,或者最外层的容器,以尽可能地重复到框的最大大小

    或者,只需使用:

    border: solid #000; border-width: 0 1px; 边框:实心#000; 边框宽度:0 1px;
    在外部div上,我删除了所有元素的边距和填充,以防止文档边缘和边框之间出现间隙

     * { margin: 0; padding: 0; }
    
    要使用#wrapper和#content div上的100%高度,请使用以下命令:

    这就是我得到的:


    稍微改变了布局

    .wrapper
    中,我删除了所有高度信息

    #content
    中,我删除了
    高度:auto!important;
    并将
    高度:100%;
    外包给

    html #content { height: 100%; }
    
    就在
    #content
    .wrapper

    现在它的工作方式应该是这样的(即使有图形边框)。初始高度为100%,如果内容超过窗口高度,则继续使用边框:

    html,
    身体{
    身高:100%;
    }
    #内容{
    保证金:0自动;
    宽度:950px;
    /*这才是真正的交易:*/
    /*背景:url(“img/content_left.png”)左上角的repeat-y*/
    /*这只是一个例子*/
    左边框:1px纯黑;
    最小高度:100%;
    }
    #内容包装器{
    /*这才是真正的交易:*/
    /*背景:url(“img/content\u right.png”)右上角重复-y*/
    /*这只是
    
    html #content { height: 100%; }