html - 如何将特定的 div 元素向右移动
问题描述
这是jsfiddle。我需要将通知 div 移动到右上角。如何实现这一点?我尝试了浮动正确但无法正常工作
https://jsfiddle.net/akhilRT/4hzdbqux/
请试试这个
.notice {
display: block;
position: static;
float: right;
border-radius: 6px;
font-size: 1.2rem;
padding: 1rem;
font-family: Arial, Helvetica, sans-serif;
margin-top: 1rem;
background-color: green;
color: hsla(0, 0%, 0%, 1);
color: var(--text);
transition: height .5s ease-in, opacity .5s ease-in;
word-wrap: break-word;
word-break: break-word;
}
<div class="notice is-success x-hidden-focus">
<p class="alert-title">
<span class="docon docon-lightbulb" aria-hidden="true">…</span> Tip
</p>
<p>
Using conventional routing with the default route allows you to build the application quickly without having to come up with a new URL pattern for each action you define. For an application with CRUD style actions, having consistency for the URLs across
your controllers can help simplify your code and make your UI more predictable.
</p>
</div>
解决方案
body {
background-color: #2e2e2e
}
.container {
float: right;
width: 200px;
position: absolute;
right: 0;
}
p {
color:white
}
.alert {
display: block;
position: relative;
border-radius: 6px;
font-size: 1rem;
padding: 1rem;
margin-top: 1rem;
background-color:green;
color: hsla(0,0%,0%,1);
color: var(--text);
transition: height .5s ease-in, opacity .5s ease-in;
word-wrap: break-word;
word-break: break-word;
}
.notice {
display: block;
position: static;
float:right;
border-radius: 6px;
font-size: 1.2rem;
padding: 1rem;
font-family:Arial, Helvetica, sans-serif;
margin-top: 1rem;
background-color: green;
color: hsla(0,0%,0%,1);
color: var(--text);
transition: height .5s ease-in, opacity .5s ease-in;
word-wrap: break-word;
word-break: break-word;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<link href="Content/bootstrap.min.css" rel="stylesheet" />
<link href="Custom.css" rel="stylesheet" />
</head>
<body>
<div class="container">
<div class="row">
<div class="col-xs-6">
<div class="well">
<form>
<div class="form-group">
<label>First Name</label>
<input type="text" class="form-control" placeholder="First Name" />
</div>
<div class="form-group">
<label>Last Name</label>
<input type="text" class="form-control" placeholder="last name" />
</div>
<div class="form-group">
<label for="email">Email</label>
<input type="text" name="email" class="form-control" placeholder="email" />
</div>
<div class="form-group">
<input type="button" class="btn btn-danger" value="Register" />
</div>
</form>
</div>
<div class="alert is-success x-hidden-focus">
<p class="alert-title">
<span class="docon docon-lightbulb" aria-hidden="true">…</span>
Tip
</p>
<p>
Using conventional routing with the default route allows you to build the application quickly without having to come up with a new URL pattern for each action you define. For an application with CRUD style actions, having consistency for the URLs across your controllers can help simplify your code and make your UI more predictable.
</p>
</div>
<div class="notice is-success x-hidden-focus">
<p class="alert-title">
<span class="docon docon-lightbulb" aria-hidden="true">…</span>
Tip
</p>
<p>
Using conventional routing with the default route allows you to build the application quickly without having to come up with a new URL pattern for each action you define. For an application with CRUD style actions, having consistency for the URLs across your controllers can help simplify your code and make your UI more predictable.
</p>
</div>
</div>
</div>
</div>
</body>
</html>
推荐阅读
- php - 我可以消除在 html 中使用隐藏表单字段在数据是所有表行的行 ID 的页面之间传递数据吗
- javascript - 数据表中选择元素中的动态过滤值
- javascript - 从原地数组中删除项目的有效算法
- python - 提高我在 Python 中的预测技术的精度
- azure - 如何防止 Azure API 管理将订阅密钥查询参数传递给逻辑应用?
- r - 如何减少和融合列表中的数据框
- image-processing - 测量不同图像之间的相似性?
- autodesk-forge - 无法从 autodesk-forge 查看器面板中删除默认按钮 (Autodesk.Viewing.Private.GuiViewer3D)
- amazon-web-services - 在新的 Amazon Linux 2 上的 AWS Elastic Beanstalk 中创建 systemd 服务
- email - 从 Google 表单发送个性化电子邮件