我正在尝试使用带有透明边框背景的图像背景上创建一种带有单词的顶部横幅,但不幸的是,我似乎无法正确对齐它。它一直倾向于页面的右端。有什么想法吗?
以下是我的代码示例,您将看到我尝试重置bor类的边距,认为它可能会有所帮助,但它并没有真正做任何事情。我也尝试重置代码的其他部分的边距但没有任何效果。也许这是定位,但我似乎无法让它发挥作用。
CSS
.full{
min-height: 100%;
background-color: white;
/*background-image: linear-gradient(to right, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0.3) 90%), url("america/cservice.jpeg");*/
/*background-blend-mode: lighten;*/
padding-top:25px ;
color: #5a5a5a;
/*color: black;*/
padding-bottom: 20px;
text-align: center;
align-items: center;
border-top: 5px solid rgba(0, 0, 102, 0.5);
border-bottom: 5px solid rgba(0, 0, 102, 0.5);
font-family: "Palatino Linotype", "Book Antiqua", Palatino, serif;
}
.image{
width: 100%;
height: 280px;
background-image: url(america/news2.png);
background-size: cover;
background-repeat: no-repeat;
position: relative;
padding-top: 20px;
padding-bottom: 20px;
}
.bor {
position: absolute;
border: 5px solid;
border-color: rgba(255, 255, 255, 0.5);
padding-top:;
padding-bottom:;
background-color: rgba(133, 133, 173, 0.4);
margin-left: 0px;
margin-right: ;
}
h2 {
position: absolute;
width: 100%;
color: black;
font-size: 40px;
padding-top: 85px;
}
h4 {
position: relative;
width: 100%;
color: white;
font-size: 30px;
padding-top: 155px;
font-stretch: ultra-expanded;
}
b{
border: 5px solid black;
padding-right: 25px;
padding-left: 25px;
margin-left: 20px;
margin-right: 20px;
color: white;
font-weight: 900;
font-size: 40px;
}
HTML
<div class="full">
<div id="section">
<h1 class="text-center">—News Feed—</h1>
<br>
<hr>
<div class="image">
<center><span class="bor">
<h2>Weekly<b>Report</b></h2>
<br>
<h4>Catch up on all the latest news regarding the world</h4>
</span></center>
</div>
</div>
</div>
答案 0 :(得分:0)
这是一个有效的例子:
<div class="full">
<div id="section">
<h1 class="text-center">—News Feed—</h1>
<br>
<hr>
<div class="image">
<center><span class="bor">
<h2>Weekly<b>Report</b></h2>
<br>
<h4>Catch up on all the latest news regarding the world</h4>
</span></center>
</div>
</div>
</div>
.bor
你有这个问题,因为你的top
班级有绝对的位置。这意味着您必须使用bottom
,left
,right
或if let crew = user!["crew"] as? [String:Any], let crewQR = crew["crew_qrcode"] as? String {
let imageUrlString = "http://52.221.231.3/gv/\(crewQR)"
let imageUrl:URL = URL(string: imageUrlString)!
//print(imageUrlString)
DispatchQueue.global(qos: .userInitiated).async {
let imageData:NSData = NSData(contentsOf: imageUrl)!
DispatchQueue.main.async {
let image = UIImage(data: imageData as Data)
self.QRimg.image = image
self.QRimg.contentMode = UIViewContentMode.scaleAspectFit
self.view.addSubview(self.QRimg)
}
}
}
属性指定其父级中的位置。
希望这有帮助!