gpt4 book ai didi

javascript - Bootstrap : More Elegant way to move a div on scroll

转载 作者:行者123 更新时间:2023-11-28 08:24:16 29 4
gpt4 key购买 nike

当我向下滚动浏览器时,我试图让一个 div 保持在右上角。在桌面上查看时看起来不错。但是在平板电脑等上查看时它是一团糟。是否有更优雅的方式来定位 div,以便用户在所有屏幕中向下滚动时看到。我正在使用 Bootstrap 。这是 DEMO 这是 HTML Bootstrap 代码:

<!DOCTYPE html>
<html lang="en" ng-app="ShopCartApp">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="../../favicon.ico">

<title>Starter Template for Bootstrap</title>

<!-- Bootstrap core CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
<style type="text/css">
body {
padding-top: 50px;
}
.starter-template {
padding: 40px 15px;
text-align: center;
}
#divTotal{
background-color: green;

}
</style>


</head>

<body>



<div class="container">

<div class="row">
<div class="col-md-8">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">Panel title</h3>
</div>
<div class="panel-body">
<div class="radio">
<label><input type="radio" name="optradio">Option 1</label>
</div>
<div class="radio">
<label><input type="radio" name="optradio">Option 1</label>
</div>
<div class="radio">
<label><input type="radio" name="optradio">Option 1</label>
</div>
</div>
</div>

<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">Panel title</h3>
</div>
<div class="panel-body">
<div class="radio">
<label><input type="radio" name="optradio1">Option 1</label>
</div>
<div class="radio">
<label><input type="radio" name="optradio1">Option 1</label>
</div>
<div class="radio">
<label><input type="radio" name="optradio1">Option 1</label>
</div>
</div>
</div>

<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">Panel title</h3>
</div>
<div class="panel-body">
<div class="radio">
<label><input type="radio" name="optradio2">Option 1</label>
</div>
<div class="radio">
<label><input type="radio" name="optradio2">Option 1</label>
</div>
<div class="radio">
<label><input type="radio" name="optradio2">Option 1</label>
</div>
</div>
</div>

<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">Panel title</h3>
</div>
<div class="panel-body">
<div class="radio">
<label><input type="radio" name="optradio3">Option 1</label>
</div>
<div class="radio">
<label><input type="radio" name="optradio3">Option 1</label>
</div>
<div class="radio">
<label><input type="radio" name="optradio3">Option 1</label>
</div>
</div>
</div>
</div>

<div style="position:fixed;top:20px;float:right;right:0px;" class="col-md-4">
<div class="panel panel-primary">
<div id="divTotal" class="panel-heading">
<h3 class="panel-title">Total</h3>
</div>
<div class="panel-body">
<h2>Total</h2>
</div>
</div>
</div>
</div><!-- /.row -->


</div><!-- /.container -->


<script type="text/javascript" src="angular.js"></script>
</body>
</html>

最佳答案

<div class="container">

<div class="row">
<div style="position:fixed;top:20px;float:left;left:0px;"class="col-sm-8">

关于javascript - Bootstrap : More Elegant way to move a div on scroll,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28599671/

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