gpt4 book ai didi

css - 比例中心一个 div 保持缩放选项

转载 作者:太空宇宙 更新时间:2023-11-04 14:55:50 24 4
gpt4 key购买 nike

我正在尝试这个 404 错误页面:

Error page

如何使图像以正确的比例居中显示在屏幕上并调整大小?我尝试添加边距,但背景图像扩展到整个页面!

Here is the Fiddle

代码

<div id="tv">
<div id="content"> <a href="http://blog.spoongraphics.co.uk/" id="logo"><img src="http://media.dday.it/roby/404/404_files/images/ddaylog.png" alt="DDay Logo"/></a>
<h1 class="scale1" style="font-size: 115.2px;">404</h1>

<h2 class="scale2" style="font-size: 38.4px;"><span>Non c'è nulla</span> su questa frequenza</h2>

<p class="scale3" style="font-size: 50px;">Cambia canale e torna su <a href="http://www.dday.it/">DDay.it</a> oppure chiedi aiuto <a href="http://www.dday.it/contact">all'antennista</a>
</p>
</div>
</div>

CSS

@font-face {
font-family:'Montserrat';
font-style: normal;
font-weight: 700;
src: local('Montserrat-Bold'), url(http://themes.googleusercontent.com/static/fonts/montserrat/v3/IQHow_FEYlDC4Gzy_m8fcgFhaRv2pGgT5Kf0An0s4MM.woff) format('woff');
}
body, div, h1, h2, h3, h4, h5, h6, p, ul, ol, li, dl, dt, dd, img, form, fieldset, input, textarea, blockquote {
margin: 0;
padding: 0;
border: 0;
}
body {
background-color: #000;
background-image: url(http://media.dday.it/roby/404/404_files/images/static.gif);
font-family:'Montserrat', sans-serif;
text-transform: uppercase;
letter-spacing: 0.3em;
font-size: 62.5%;
}
body, html, div {
height: 100%;
}
#tv {
background-image: url(http://media.dday.it/roby/404/404_files/images/tv.png), url(http://media.dday.it/roby/404/404_files/images/shading.png);
background-size: 100% 100%;
}
#content {
width: 60%;
height: 65%;
position: relative;
top: 20%;
left: 10%;
text-align: center;
color: #fff;
}
#logo {
display: block;
width: 50%;
margin: 0 auto 2em auto;
}
#logo img {
max-width: 100%;
}
h1 {
font-family: Serif;
font-size: 10em;
margin: 0 0 0.1em 0;
}
h2 {
font-size: 3em;
text-transform: uppercase;
line-height: 1.5em;
margin: 0 0 1.3em 0;
}
h2 span {
font-size: 2.05em;
display: block;
}
p {
font-size: 2em;
}
a {
color: #4be300;
text-decoration: none;
}
a:hover {
color: #4be300;
}

最佳答案

再见,:)

您可以使用 mediaqueires 来设置字体大小: http://jsfiddle.net/LAKXK/3/

@font-face {
font-family:'Montserrat';
font-style: normal;
font-weight: 700;
src: local('Montserrat-Bold'), url(http://themes.googleusercontent.com/static/fonts/montserrat/v3/IQHow_FEYlDC4Gzy_m8fcgFhaRv2pGgT5Kf0An0s4MM.woff) format('woff');
}
body, div, h1, h2, h3, h4, h5, h6, p, ul, ol, li, dl, dt, dd, img, form, fieldset, input, textarea, blockquote {
margin: 0;
padding: 0;
border: 0;
}
body {
background-color: #000;
background-image: url(http://media.dday.it/roby/404/404_files/images/static.gif);
font-family:'Montserrat', sans-serif;
text-transform: uppercase;
letter-spacing: 0.3em;
font-size: 62.5%;
}
body, html, div {
height: 100%;
}
#tv {
background-image: url(http://media.dday.it/roby/404/404_files/images/tv.png), url(http://media.dday.it/roby/404/404_files/images/shading.png);
background-size: 100% 100%;
}
#content {
width: 60%;
height: 65%;
position: relative;
top: 20%;
left: 10%;
text-align: center;
color: #fff;
}
#logo {
display: block;
width: 50%;
margin: 0 auto 2em auto;
}
#logo img {
max-width: 100%;
}
h1 {
font-family: Serif;
font-size: 10em;
margin: 0 0 0.1em 0;
}
h2 {
font-size: 3em;
text-transform: uppercase;
line-height: 1.5em;
margin: 0 0 1.3em 0;
}
h2 span {
font-size: 2.05em;
display: block;
}
p {
font-size: 2em;
}
a {
color: #4be300;
text-decoration: none;
}
a:hover {
color: #4be300;
}
@media all and (max-width:2700px) {html {font-size:16px;transition:1s;}}
@media all and (max-width:2000px) {html {font-size:14px;transition:1s;}}
@media all and (max-width:1600px) {html {font-size:13px;transition:1s;}}
@media all and (max-width:1200px) {html {font-size:12px;transition:1s;}}
@media all and (max-width:1100px) {html {font-size:11px;transition:1s;}}
@media all and (max-width: 900px) {html {font-size:10px;transition:1s;}}
@media all and (max-width: 700px) {html {font-size:9px;transition:1s;}}
@media all and (max-width: 500px) {html {font-size:8px;transition:1s;}}
@media all and (max-width: 300px) {html {font-size: 6px;transition:1s;}}

并在您的在线样式中使用 em(您应该将其移至 CSS 文件)

<script src="./404_files/jquery.fittext.js"></script>
<script src="./404_files/scripts.js"></script>
<div id="tv">
<div id="content"> <a href="http://blog.spoongraphics.co.uk/" id="logo"><img src="http://media.dday.it/roby/404/404_files/images/ddaylog.png" alt="DDay Logo"/></a>
<h1 class="scale1" style="font-size: 3em;">404</h1>

<h2 class="scale2" style="font-size: 3em;"><span>Non c'è nulla</span> su questa frequenza</h2>

<p class="scale3" style="font-size: 3em;">Cambia canale e torna su <a href="http://www.dday.it/">DDay.it</a> oppure chiedi aiuto <a href="http://www.dday.it/contact">all'antennista</a>
</p>
</div>
</div>

贝拉·帕吉娜

关于css - 比例中心一个 div 保持缩放选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16987733/

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