gpt4 book ai didi

html - 为什么内容从输入文本字段下方开始?

转载 作者:太空宇宙 更新时间:2023-11-03 21:28:55 24 4
gpt4 key购买 nike

为什么内容从输入文本字段下方开始?

这是一个 fiddle :http://jsfiddle.net/q646Ljg6/4/

HTML:

<div id="navigation" class="navigation">
<div id="dropmenu" class="dropmenu">
<login>
<ul>
<li> <a href="#" ><span id="cart-button" class="flaticon flaticon-cart" aria-hidden="true"></span></a>

</li>
<li> <a href="javascript:void(0);">Dropdown C</a>

<ul>
<li><a href="#" >Option 1</a>
</li>
<li><a href="#" >Option 2</a>
</li>
<li><a href="#" >Option 3</a>
</li>
</ul>
</li>
</ul>
</login>
<ul>
<li> <a href="/">Home</a>

</li>
<li> <a href="javascript:void(0);" >Dropdown A</a>

<div class="sub-menu">
<div class="sub-menu-inner">
<div>
<ul>
<li><a href="#" >Dropdown A - 1</a>
</li>
<li><a href="#" >Dropdown A - 2</a>
</li>
</ul>
</div>
</div>
<!-- /sub-menu-inner -->
</div>
<!-- /sub-menu -->
</li>

<li> <a href="javascript:void(0);" >Dropdown B</a>

<div class="sub-menu">
<div class="sub-menu-inner">
<div>
<ul>
<li> <a href="#" >Dropdown B - 1</a>

<ul>
<li><a href="#" >Dropdown B - 1 - 1</a>
</li>
</ul>
</li>
<li><a href="#" >Dropdown B - 2</a>
<ul>
<li><a href="#" >Dropdown B - 2 - 1</a>
</li>
<li><a href="#" >Dropdown B - 2 - 2</a>
</li>
</ul>
</li>
</ul>
</div>
</div>
<!-- /sub-menu-inner -->
</div>
<!-- /sub-menu -->
</li>
<li style="float:none;overflow:hidden;">
<div class="dark width-max"> <span>
<input id="quick-search" data-load="content" data-url="/quicksearch" class="search" type="text" placeholder="Quick Search" maxlength="50" autocomplete="off">
<div id="search-results" class="search-results"></div>
</span>

</div>
</li>
</ul>
</div>
</div>
<div>
content content content content content content content content content content content content content content content content content content content content content content content content </div>

Javascript:

var currentTop = -1;
var currentSub = -1;
var currentProfile = -1;
//var topMenu = '';
//var subMenu = '';
var lastToggled = '';

function InitNav() {
//$body.on('click', '#dropmenu > ul > li > a', ToggleTop);
$('#dropmenu > ul > li > a', 'body').mouseenter(ToggleTop);
$('#dropmenu', 'body').mouseleave(ToggleTop);

$body.on('click', '#dropmenu > ul > li ul > li > a', ToggleSub);
$('#dropmenu login a', 'body').mouseenter(ToggleProfileIn).mouseleave(ToggleProfileOut);
$body.on('click', '#dropmenu login a', ToggleProfile);
}

function ToggleTop(e) {
var $listItems = $('#dropmenu > ul > li');

if (currentProfile !== -1) { // reset profile if needed
lastToggled.removeClass('toggled');
}

if (currentTop !== -1) { // reset top menu
$listItems.eq(currentTop).removeClass('toggled');
}

var $currentTarg = $(e.currentTarget);
var $item = $currentTarg.parent('li');
var index = $item.index();

if (currentTop === index) { // reset
$item.removeClass('toggled');
currentTop = -1;
} else { // set
$item.addClass('toggled');
currentTop = index;
}


return false;
}

function ToggleSub(e) {
var $listItems = $('#dropmenu .sub-menu-inner > div > ul > li');

if (currentSub !== -1) { // reset
$listItems.removeClass('selected');
}

var $currentTarg = $(e.currentTarget);
var $item = $currentTarg.closest('#dropmenu .sub-menu-inner > div > ul > li');
var index = $item.index();

// set
$item.addClass('selected');
currentSub = index;

return false;
}

function ToggleProfileIn(e) {
var $listItems = $('#dropmenu > ul > li');

if (currentTop !== -1) { // reset
lastToggled = $listItems.eq(currentTop).removeClass('toggled');
}
}

function ToggleProfile(e) {
currentTop = -1;

var $listItems = $('#dropmenu login > ul > li');

if (currentProfile !== -1) { // reset
$listItems.removeClass('toggled');
}

var $currentTarg = $(e.currentTarget);
var $item = $currentTarg.closest('#dropmenu login > ul > li');
var index = $item.index();

// set
currentProfile = index;
lastToggled = $item.addClass('toggled');

return false;
}

function ToggleProfileOut(e) {
if (currentTop !== -1) { // restore
lastToggled.addClass('toggled');
}
}

InitNav();

CSS:

.navigation {
width: 100%;
height: 36px;
background-color: rgb(243, 245, 245);
}
.dropmenu {
position: relative;
width: 100%;
height: 36px;
font-weight: bold;
background: #3e494b;
/* menu background color */
}
.dropmenu ul {
list-style-type: none;
z-index: 50;
}
/* first level ul style */

/* .dropmenu > ul, */
.dropmenu .sub-menu-inner {
margin: 0 auto;
/*
background: rgb(130, 160, 46);
background: rgba(255, 160, 46, 0.92);
*/
}
.dropmenu > ul > li {
float: left;
z-index: 50;
}
.dropmenu > ul > li:nth-of-type(1) {
width: 187px;
}
.dropmenu > ul > li > a {
display: inline-block;
padding: 10px 20px;
color: #b1b6b9;
/* grey menu text color */
}
.dropmenu > ul > li > a:hover {
padding: 10px 20px 10px;
/* correlation with underline */
/*
border-top: 3px solid;
border-top-color: #b1b6b9;
*/
background-color: #596466;
/* #3e494b; /* dark grey */
color: #ffffff;
}
.dropmenu > ul > li.toggled > a, .dropmenu > ul > li.toggled > a:hover {
padding: 10px 20px 10px;
/* correlation with underline */
/*
border-top: 3px solid;
border-top-color: #b1b6b9;
*/
background-color: #596466;
/* #3e494b; /* dark grey */
color: #ffffff;
}
/* sub-menu */
.dropmenu .sub-menu {
display: none;
position: absolute;
/* background: #00a3da; */
width: 100%;
left: 0;
-webkit-box-shadow: 0 4px 5px -5px #000000;
-moz-box-shadow: 0 4px 5px -5px #000000;
box-shadow: 0 4px 5px -5px #000000;
}
.toggled .sub-menu {
display: block;
width: 100%;
background: #596466;
/* sub menu color */
/* border: 1px solid red; /**/
}
.dropmenu .sub-menu-inner > div {
width: 100%;
height: 100%;
float: left;
/* border: 1px solid green; /**/
}
/*
.dropmenu .sub-menu-inner > div > ul {

}
/**/
.dropmenu .sub-menu-inner > div > ul > li {
display: inline;
overflow: hidden;
position: relative;
}
.dropmenu .sub-menu-inner > div > ul > li:nth-of-type(1) {
margin-left: 187px;
}
.dropmenu .sub-menu-inner > div > ul > li > a {
padding: 10px 20px;
color: #d5d5d5;
/* border: 1px solid red; */
}
.dropmenu .sub-menu-inner > div > ul > li > a:hover {
padding: 10px 20px 10px;
/* correlation with underline */
color: #ffffff;
}
.dropmenu .sub-menu-inner > div > ul > li.selected > a, .dropmenu .sub-menu-inner > div > ul > li.selected > a:hover {
padding: 10px 20px 10px;
/* correlation with underline */
/*
background-color: rgb(243, 245, 245);
background-color: rgba(243, 245, 245, 0.9); /* almost white */
color: #ffffff;
}
.dropmenu .sub-menu-inner:before, .dropmenu .sub-menu-inner:after {
content:" ";
display: table;
}
.dropmenu .sub-menu-inner:after {
clear: both;
}
.dropmenu .sub-menu-inner > div a {
line-height: 36px;
}
/* drop-sub-menu */
.dropmenu .sub-menu-inner ul ul {
display: none;
position: absolute;
}
.dropmenu .sub-menu-inner ul > li:hover ul {
display: block;
left: 0px;
}
.dropmenu .sub-menu-inner ul > li > ul > li > a {
display: block;
padding: 0px 20px;
width: 145px;
background: #596466;
/* sub menu color */
color: #d5d5d5;
}
.dropmenu .sub-menu-inner ul > li > ul > li > a:hover {
/* background: #798486; /* sub menu hover color */
color: #ffffff;
}
/* login menu */
.dropmenu login ul {
margin: 0;
}
.dropmenu login > ul > li {
position: relative;
float: right;
}
.dropmenu login > ul > li > a {
display: inline-block;
padding: 10px 20px;
color: #b1b6b9;
/* grey menu text color */
}
.dropmenu login > ul > li > a:hover {
background-color: #596466;
/* #3e494b; /* dark grey */
color: #ffffff;
}
#cart-button {
font-size: 14px;
}
/* login drop-down */
.dropmenu login ul ul {
display: none;
position: absolute;
right: 0;
top: 100%;
}
.dropmenu login ul > li:hover ul {
display: block;
}
/* login sub-menu */
.dropmenu login > ul > li > ul > li > a {
display: inline-block;
width: 100px;
padding: 10px 20px;
background: #3e494b;
/* menu background color */
color: #b1b6b9;
/* light grey */
}
.dropmenu login > ul > li > ul > li > a:hover {
background-color: #596466;
/* #3e494b; /* dark grey */
color: #ffffff;
}
.dropmenu login > ul > li.toggled > a, .dropmenu login > ul > li.toggled > a:hover {
padding: 10px 20px 10px;
/* correlation with underline */
background-color: #596466;
color: #ffffff;
}
.width-max {
margin: 2px 10px 0 5px;
float:none;
overflow:hidden;
}

最佳答案

将内容周围的 div 设置为 clear: both;

<div style="clear: both;">content content...</div>

关于html - 为什么内容从输入文本字段下方开始?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30775213/

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