我正试图在右下方设置一个div。但我不知道哪个设备屏幕(大或小),所以我认为我应该保持正确:100px;或类似的东西。我不能保留左边:900px或400px因为我不知道设备有多大。 我正在尝试设置属性css margin-right但不成功。 这是我的测试代码。请帮帮我。 同样,margin-bottom在这里看起来是非法的。 This picture shows my goal
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
<style>
.worldcup{
margin-right: 40%;
}
.euro{
margin-left: 40%;
}
</style>
</head>
<body >
<div><p class="worldcup">worldcup</p></div>
<div><p class="euro">euro</p></div>
</body>
</html>
答案 0 :(得分:0)
put text-align:right;它可以解决你的问题
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
<style>
.worldcup{
margin-right: 40%;
}
.euro{
margin-left: 40%;
text-align: right;
float: right;
}
</style>
</head>
<body >
<div><button class="worldcup">worldcup</button></div>
<div><button class="euro">euro</button></div>
</body>
</html>
答案 1 :(得分:0)
这是它的引导代码:
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js">
<!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<!--[if lt IE 7]>
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="#">upgrade your browser</a> to improve your experience.</p>
<![endif]-->
<div class="container">
<div class="row">
<div class="col-xs-4 col-sm-4 col-lg-4 col-xl-4" style="text-align: left">
WORLDCUP
<div class="col-xs-4 col-sm-4 col-lg-4 col-xl-4">
</div>
<div class="col-xs-4 col-sm-4 col-lg-4 col-xl-4">
</div>
</div>
</div>
<div class="row">
<div class="col-xs-4 col-sm-4 col-lg-4 col-xl-4">
</div>
<div class="col-xs-4 col-sm-4 col-lg-4 col-xl-4">
</div>
<div class="col-xs-4 col-sm-4 col-lg-4 col-xl-4" style="text-align: right">
EURO
</div>
</div>
</div>
<script src="" async defer></script>
</body>
</html>