gpt4 book ai didi

html - 如何让个人资料图片居中对齐?

转载 作者:行者123 更新时间:2023-11-27 23:29:51 25 4
gpt4 key购买 nike

我无法让个人资料图片居中。关于如何做到这一点的任何想法?我尝试使用 float 使后退按钮内联,但它会将个人资料图片稍微向右移动。我如何让它对齐?

Output in browser

这是我的 HTML 代码。

<!DOCTYPE html>
<html lang="en">
<head>
<title>About Me</title>

<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>

<link rel="stylesheet" type="text/css" href="bootstrap.css"/>

<link rel="stylesheet" type="text/css" href="blackbg.css"/>
</head>
<body>
<a href="#" class="myButton">Back</a>
<header>
<img id="profilepic" src="http://i.imgur.com/rEVubAf.jpg">
<h1>Zheng Yuxiang</h1>
</header>
<article>
<p>I am a fuccboi that loves bad bitches. Oh and I love Yeezy too and his overpriced sneakers.</p>
<img src="http://sneakerbardetroit.com/wp-content/uploads/2015/11/adidas-yeezy-350-boost-moonrock-release.jpg" alt="Yeezy 350" width=600px id="yeezy">
</article>

</body>

这是我的 CSS 代码。

body {
background-color: black;
}
header {
text-align: center;
color:white;
}
#profilepic {
margin: 40px 0px 0px px;
border: 4.5px solid white;
border-radius: 100px;
}
h1 {
font-family:avenir ,sans-serif;
font-variant: light;
font-size:50px;
}
nav {
font-size: 15px;
}
a {
margin:5px;
color:white;
}
@media (max-width: 750px) {
h1 {
font-size: 25px
}
nav {
font-size: 10px;
}
}
article {
text-align: center;
}
#yeezy {
padding:20px;
}
p {
color:#b7b1b5;
}
.myButton {
margin-top: 40px;
margin-left: 40px;
background-color:#ededed;
-moz-border-radius:42px;
-webkit-border-radius:42px;
border-radius:42px;
display:inline-block;
cursor:pointer;
color:#777777;
font-family:avenir;
font-size:17px;
padding:14px 22px;
text-decoration:none;
float:left;
}
.myButton:hover {
background-color:#dfdfdf;
}
.myButton:active {
position:relative;
top:1px;
}

最佳答案

试试这个

body {
background-color: black;
}
header {
text-align: center;
color:white;
position: relative;
}
#profilepic {
margin: 40px 0px 0px px;
border: 4.5px solid white;
border-radius: 100px;
}
h1 {
font-family:avenir ,sans-serif;
font-variant: light;
font-size:50px;
}
nav {
font-size: 15px;
}
a {
margin:5px;
color:white;
}
@media (max-width: 750px) {
h1 {
font-size: 25px
}
nav {
font-size: 10px;
}
}
article {
text-align: center;
}
#yeezy {
padding:20px;
}
p {
color:#b7b1b5;
}
.myButton {
position: absolute;
top: 0px;
left: 0px;
margin-top: 40px;
margin-left: 40px;
background-color:#ededed;
-moz-border-radius:42px;
-webkit-border-radius:42px;
border-radius:42px;
display:inline-block;
cursor:pointer;
color:#777777;
font-family:avenir;
font-size:17px;
padding:14px 22px;
text-decoration:none;
float:left;
}
.myButton:hover {
background-color:#dfdfdf;
}
.myButton:active {
position:relative;
top:1px;
}
<html lang="en">
<head>
<title>About Me</title>

<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>

<link rel="stylesheet" type="text/css" href="bootstrap.css"/>

<link rel="stylesheet" type="text/css" href="blackbg.css"/>
</head>
<body>

<header>
<img id="profilepic" src="http://i.imgur.com/rEVubAf.jpg">
<h1>Zheng Yuxiang</h1>

<a href="#" class="myButton">Back</a>
</header>
<article>
<p>I am a fuccboi that loves bad bitches. Oh and I love Yeezy too and his overpriced sneakers.</p>
<img src="http://sneakerbardetroit.com/wp-content/uploads/2015/11/adidas-yeezy-350-boost-moonrock-release.jpg" alt="Yeezy 350" width=600px id="yeezy">
</article>

</body>

关于html - 如何让个人资料图片居中对齐?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36449644/

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