gpt4 book ai didi

html - 文本标题 block 在 3 列布局标题的 div 中右侧 float

转载 作者:太空宇宙 更新时间:2023-11-04 10:44:49 24 4
gpt4 key购买 nike

我有 3 列布局,一切正常: http://codepen.io/cove3010/pen/dGEmaZ

/* 1) CSS reset http://meyerweb.com/eric/tools/css/reset/ */
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}

/* 2) Skeleton */
.header{
height:149px;
background: transparent url("http://www.hromov.net/templates/hromov_main/images/right_top.jpg")
no-repeat;
background-position: top right;
}
.main_cont_width {width:1003px; margin:0 auto;}
.footer {background: #D5BAE4;}
.layout { overflow: hidden;}
.col1 { background: #C7E3E4; float: left; width: 200px; }
.col2 { background: #E0D2C7; margin: 0 200px 0 200px; /* Отступ справа и слева */}
.col3 { background: #ECD5DE; width: 200px; float: right; }

/* 3) Header */
.f_l {
float:left;

}
.f_r {
background-color:gold;
position:relative;
top:50px;
right:50px;
float:right;
}

/*4) Float divs clearfix*/
.clearfix:before,
.clearfix:after {
content: ""; /* 1 */
display: table; /* 2 */
}

.clearfix:after {
clear: both;
}

.clearfix {
*zoom: 1;
}
<html>
<head>
<meta charset="utf-8">
</head>
<body>

<div class="main_cont_width">
<div class="header clearfix">
<img src="http://www.hromov.net/templates/hromov_main/images/guitar_top.jpg"><img src="http://www.hromov.net/templates/hromov_main/images/cassete_top.jpg">

</div>
<div class="layout">
<div class="col1"><div class="wrap">Left column</div></div>
<div class="col3"><div class="wrap">Right column</div></div>
<div class="col2">Center column</div>
</div>
<div class="footer">Footer</div>
</div>
</body>
</html>

我需要在标题中添加自定义文本,所以我决定用 div 来做。
我在 div 中包装了 2 张左图,使其 float :左,新文本 div block 带有 float :右。父 block 的 Clearfix。但是出了点问题,clearfix 没有像我预期的那样工作:

http://codepen.io/cove3010/pen/wMbmQR

/* 1) CSS reset http://meyerweb.com/eric/tools/css/reset/ */
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}

/* 2) Skeleton */
.header{
height:149px;
background: transparent url("http://www.hromov.net/templates/hromov_main/images/right_top.jpg")
no-repeat;
background-position: top right;
}
.main_cont_width {width:1003px; margin:0 auto;}
.footer {background: #D5BAE4;}
.layout { overflow: hidden;}
.col1 { background: #C7E3E4; float: left; width: 200px; }
.col2 { background: #E0D2C7; margin: 0 200px 0 200px; /* Отступ справа и слева */}
.col3 { background: #ECD5DE; width: 200px; float: right; }

/* 3) Header */
.f_l {
float:left;

}
.f_r {
background-color:gold;
position:relative;
top:50px;
right:50px;
float:right;
}

/*4) Float divs clearfix*/
.clearfix:before,
.clearfix:after {
content: ""; /* 1 */
display: table; /* 2 */
}

.clearfix:after {
clear: both;
}

.clearfix {
*zoom: 1;
}
<html>
<head>
<meta charset="utf-8">
</head>
<body>

<div class="main_cont_width">
<div class="header clearfix">
<div class="f_l"><img src="http://www.hromov.net/templates/hromov_main/images/guitar_top.jpg"><img src="http://www.hromov.net/templates/hromov_main/images/cassete_top.jpg"></div>
<div class="f_r">Here goes some text<br>and some more</div>
</div>
<div class="layout">
<div class="col1"><div class="wrap">Left column</div></div>
<div class="col3"><div class="wrap">Right column</div></div>
<div class="col2">Center column</div>
</div>
<div class="footer">Footer</div>
</div>
</body>
</html>

那么,我做错了什么?

最佳答案

添加position:relative于.header:

.header{
height:149px;
background: transparent url("http://www.hromov.net/templates/hromov_main/images/right_top.jpg")
no-repeat;
background-position: top right;
position: relative;
}

从 .f_l 和 f_r 中删除两个 float 并将 .f_r 位置更改为绝对位置:

.f_r {
background-color:gold;
position: absolute;
top:50px;
right:50px;
}

这会将文本放置在您需要的位置,我相信根本不需要 float 。

关于html - 文本标题 block 在 3 列布局标题的 div 中右侧 float ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35507481/

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