gpt4 book ai didi

html - CSS div溢出隐藏和 float

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

我正在尝试一些非常简单的事情:

创建一个左侧带有文本的正文,并为从最大到最小的 px 量占用所有可用空间,它可以 float 。在该 div 的右侧,我想添加一个新的 div,它的末尾将包含一个菜单。

我看了一下这个论坛并尝试了很多东西,但我无法实现我想要的。

我希望我的#rightcolumn 在可能的时候在右边,而在不可能的时候,它应该被隐藏。

我成功地找到了我想要的一切,但从来没有同时找到。

我在相关位置工作,使用 inline 而不是 float,没有 float 它不在同一行。

这是我的实际代码:

    <!DOCTYPE html>
<html>
<head>
<style>
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;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}



img
{
float:bottom;

border:1px dotted black;
margin:0px 0px 15px 20px;
}
p {
padding: 10px;
}

#rightcolumn{
margin-left: -150px;
width: 150px;
height: 100px;
/* float:left;*/
background: #CC33FF;
float:left;
overflow:hidden;
}

#wrapper {
width: 100%;
min-width: 1000px;
max-width: 1000px;
margin: 0 auto;
white-space:nowrap;

}


#contentliquid {
float: left;
width: 100%;
min-width: 1000px;
float:left;
}

#content {

background: #FFFFFF;
margin-left: 0px;
min-width: 1000px;
float:left;
}

</style>
</head>

<body>
<div id="wrapper">

<div id="contentliquid">
<div id="content">
Test coucou
</div>
</div>

<div id="rightcolumn">
<p>This is right</p>
</div>

</div>
</body>

</html>

最佳答案

如果我理解你的问题是正确的。我会说使用 JavaScript 会很容易

$(文档).ready(函数(){ var length_of_content = $('#content').width();

if((length_of_content+$('#rightcolumn').width()) >= 500) {
$('#rightcolumn').css('display', 'none');
}

});

只需检查当前内容的长度并添加要显示的菜单的宽度,如果宽度 >= 500 或容器的最大尺寸应该是什么,则只需使用 #rightmenue 隐藏菜单,否则显示它.

关于html - CSS div溢出隐藏和 float ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23627527/

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