gpt4 book ai didi

css - Bootstrap 中的菜单布局

转载 作者:行者123 更新时间:2023-11-28 05:07:16 25 4
gpt4 key购买 nike

我正在使用 Bootstrap,这是我的第一次尝试。我试图在页面左侧有一个菜单,但是一旦我们展开 - 我希望菜单位于表格的顶部。所以.....我也必须要一个“过渡动画”,我在 css 中有。两天来我一直在用头撞墙,但似乎无法理解。对我所做的有什么建议吗?菜单向左 - 但它位于布局中表格的顶部......

@charset "utf-8";

/* CSS Document */

body {
background-color: black;
color: #E8E3E3;
}
.bgimage {
background-position: center center;
background-size: cover;
height: 100px;
color: #3279B6;
}
.table-striped>tbody>tr:nth-child(odd)>td,
.table-striped>tbody>tr:nth-child(odd)>th {
background-color: #3279B6;
}
@media all and (max-width: 500px) {
.item-list {
float: left;
width: auto;
padding: 10px;
background-color: #686868;
}
}
@media all and (min-width: 500px) {
.item-list div {
transition: all 1.5s;
float: left;
width: 20%;
padding: 10px;
background-color: #686868;
}
}
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Lewis Lab 1</title>

<!-- Bootstrap -->
<link href="css/bootstrap.css" rel="stylesheet">

<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>

<body>
<header class="bgimage">
<div class="container">
<h1>My Todo App...</h1>
</div>
</header>
<div class="row">
<div class="container">
<div class="col-sm-12">
<div class="item-list">
<div class="item">
<img src="http://i.stack.imgur.com/KVkTq.jpg" style="width: 20px">
</div>
<div class="item">Todos</div>
<div class="item">Add</div>
<div class="item">Edit</div>
<div class="item">More</div>
</div>
</div>
</div>
</div>
<div class="container">
<div class="col-md-10 col-xs-offset-2 col-sm-offset-0">
<table class="table table-striped">
<div>
<thead>
<tr>
<th>Id</th>
<th>Name</th>
<th>Description</th>
<th>Create TIme</th>
<th>User Email</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Dog</td>
<td>Walk the dog</td>
<td>2 pm</td>
<td>chris@thetraderguy.com</td>
</tr>
<tr>
<td>2</td>
<td>Cat</td>
<td>Feed the cat</td>
<td>3:13 pm</td>
<td>marketing@thetraderguy.com</td>
</tr>
<tr>
<td>3</td>
<td>School</td>
<td>Do Lab 1</td>
<td>6 pm</td>
<td>signals@thetraderguy.com</td>
</tr>
<tr>
<td>4</td>
<td>Work out</td>
<td>Go to gym</td>
<td>7:15 pm</td>
<td>chris@thetraderguy.com</td>
</tr>
</tbody>
</table>
</div>
</div>

<div class="container">
<div class="col-lg-12">
<div class="row">

<h1>Action Items</h1>
<form>
<label for="addTodo">Add Todo</label>
<input class="form-control" type="text" id="addTodo" placeholder="Add Todo">
<label for="details">Details</label>
<input class="form-control" type="text" id="details" placeholder="Add details">
<br>
<input class="btn btn-primary" type="submit" value="submit">
</form>
</div>
</div>
</div>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="js/jquery-1.11.3.min.js"></script>

<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="js/bootstrap.js"></script>
</body>

</html>

我得到的,而不是我想要的:

...

最佳答案

有一个打开了<div> <table class="table table-striped"> 下未关闭的标签标签。首先,请将其删除。

接下来,当分辨率小于 500px 时,就会出现您的问题。请在下面添加 CSS block :

.item-list .item {
float:left;
width: auto;
padding: 10px;
background-color: #686868;
}

进入@media all and (max-width: 500px){...}媒体查询。

您可以从这里查看添加的版本:https://jsfiddle.net/pz19r40k/1/

关于css - Bootstrap 中的菜单布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39776358/

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