gpt4 book ai didi

html - 我的文字未随屏幕尺寸调整

转载 作者:行者123 更新时间:2023-11-28 02:15:27 25 4
gpt4 key购买 nike

嘿伙计们,我希望文本“LETS SAVE PETS”和“We need you in this mission”根据屏幕尺寸做出响应,但发生的事情是当屏幕尺寸较小时它们不会缩小并最终在网站上添加大量空白区域。我也用过,但它没有按照我的意愿工作。伙计们请帮助我。我的网站是http://letsavepet.com/ .我在这里用作背景的图片与网站上的图片不同。算了吧,请帮助我。HTML和CSS代码如下

/*This is for links*/
a{text-decoration: none;
color: Black;}

div#sub{display: inline;
color: #339900;}

body {margin:0;}

/*This is for navigation*/
.topnav {
overflow: hidden;
background-color: #4caf50;
}

.topnav a {

float: left;
color: black;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
}

.topnav a:hover {
background-color: #666666;
color: white;
}

.topnav a.active {
background-color: white;
color: black;
}

/*This is the end*/

/*This is for parallax scrolling*/
body, html {
height: 100%;
}

.parallax {
/* The image used */
background-image: url('http://letsavepet.com/images/20170122_150254.jpg');

/* Full height */
height: 100%;

/* Create the parallax scrolling effect */
background-attachment: fixed;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}

/* Turn off parallax scrolling for tablets and phones. Increase the pixels if needed */
@media only screen and (max-device-width: 1024px) {
.parallax {
background-attachment: scroll;
}
}
/*This is the end*/


/*This is for header*/
body {
margin: 0;
font-family: Arial;}

.top-container {
background-color: white;
padding: 0px;
text-align: left;}

.content {
padding-top: 14px;}

.header {
padding: 0px 0px;
background: #4caf50;
color: #4caf50;
z-index:100;}

.sticky {
position: fixed;
top: 0;
width: 100%;}

.sticky + .content {
padding-top: 64px;}
/*This is the end*/

/*This is for text*/
.text {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
color: white;
font-size: 120px;}

.sub-text{ position: absolute;
top: 63%;
left: 50%;
transform: translate(-50%, -50%);
color: white;
font-size: 40px;
font-family: apple chancery;}

/*This is for footer*/
.footer {
background-color: #0b0c0c;
padding: 10px;
color: white;
padding-top: 70px;
padding-bottom: 100px;
padding-left: 40px;}

.footer_2{background-color: #1e1f21;
padding-top: 20px;
padding-bottom: 30px;
color: white; }

div#info{ color: #9fa1a3;}


.copy_reg{float:right;
display: inline-block;
padding-right: 10px; }

/*This is for media buttons*/
.fa {
padding: 6px;
font-size: 5px;
text-align: center;
text-decoration: none;
margin: 5px 5px;
}

.fa:hover {
opacity: 0.7;
}

.fa-facebook {
background: #3B5998;
color: white;}

.media{font-size: 20px;
padding-right: 60px;
float: right;
display: inline-block;}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Lets Save Pets</title>
<link rel="stylesheet" href="index.css" type="text/css" />
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body style=background:white>

<div class="header" id="myHeader">

<div class="topnav" id="myTopnav">
<a href="index.html" class="active">Home</a>
<a href="news.html">News</a>
<a href="gallery.html">Gallery</a>
<a href="joinus.html">Join Us</a>
<a href="aboutus.html">About</a>
</div>

</div>

<div class="text"><b>LETS&nbsp;SAVE&nbsp;PETS</b></div>
<div class="sub-text"><b>We need you in this mission!</b></div>

<div class="parallax"></div>

<div class="content" style="background-color:white;">

<h1><u>Saving a life is easier than you think.</u></h1>
<p><font size="5">
“You can do it!” Every day, we say those four magical words to people around the globe who
want to help animals in need but are unsure of their abilities. With some friendly encouragement
and guidance, you’ll be amazed at what you can accomplish.

<h2>Helping to save animals</h2>

Each of us can help bring about a time when there are No More Homeless Pets. In fact, that’s just
what it is going to take — every person reading this article committing to do just a little bit to
reach this goal. Sure, many of us think we can’t make a difference for one reason or another, but
the truth is that no matter how little time, money or experience you have, you can still save
an animal’s life. It’s easier than you think, and makes you feel good, too.
<br /> <br />
We’ve heard from so many of you who want to help but aren’t sure how, so we’re going to tell you
about simple ways that you can make a huge impact. It’s time to do all we can to save the lives of
homeless animals. They’re counting on us — and we know <b>you can do it!
</b></font></p>
</div>

<div class="footer">
<div class="media">FIND&nbsp;US&nbsp;ON<a href="https://www.facebook.com/letsavepet/" class="fa fa-facebook"></a></div>
CONTACT&nbsp;INFO<br /><br />
<div id="info"><i class="material-icons">local_phone</i> +91 7982189411<br /><br />
<i class="material-icons">local_post_office</i> letsavepet@gmail.com<br /><br />
<i class="material-icons">map</i> 1/5300-C, Street no.- 11,<br />
Balbir Nagar Ext., Shahdara,<br />
Delhi-110032, India</div>
</div>

<div class="footer_2">&nbsp;&nbsp; &copy; Letsavepet
<div class="copy_reg">All Rights Reserved&reg;</div></div>


<script>
function myFunction() {
var x = document.getElementById("myTopnav");
if (x.className === "topnav") {
x.className += " responsive";
} else {
x.className = "topnav";
}
}

window.onscroll = function() {myFunction()};

var header = document.getElementById("myHeader");
var sticky = header.offsetTop;

function myFunction() {
if (window.pageYOffset >= sticky) {
header.classList.add("sticky");
} else {
header.classList.remove("sticky");
}
}
</script>

</body>
</html>

最佳答案

如果您不需要 IE 11 以下的浏览器支持,我可能会使用 vw 作为字体大小。给 .text div font-size: 11vw;.sub-text: 4vw; 或根据需要调整它。两个 div 之间的间距可能需要根据不同的屏幕宽度进行调整,但字体大小会进行调整。

/*This is for links*/
a{text-decoration: none;
color: Black;}

div#sub{display: inline;
color: #339900;}

body {margin:0;}

/*This is for navigation*/
.topnav {
overflow: hidden;
background-color: #4caf50;
}

.topnav a {

float: left;
color: black;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
}

.topnav a:hover {
background-color: #666666;
color: white;
}

.topnav a.active {
background-color: white;
color: black;
}

/*This is the end*/

/*This is for parallax scrolling*/
body, html {
height: 100%;
}

.parallax {
/* The image used */
background-image: url('http://letsavepet.com/images/20170122_150254.jpg');

/* Full height */
height: 100%;

/* Create the parallax scrolling effect */
background-attachment: fixed;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}

/* Turn off parallax scrolling for tablets and phones. Increase the pixels if needed */
@media only screen and (max-device-width: 1024px) {
.parallax {
background-attachment: scroll;
}
}
/*This is the end*/


/*This is for header*/
body {
margin: 0;
font-family: Arial;}

.top-container {
background-color: white;
padding: 0px;
text-align: left;}

.content {
padding-top: 14px;}

.header {
padding: 0px 0px;
background: #4caf50;
color: #4caf50;
z-index:100;}

.sticky {
position: fixed;
top: 0;
width: 100%;}

.sticky + .content {
padding-top: 64px;}
/*This is the end*/

/*This is for text*/
.text {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
color: white;
font-size: 11vw;}

.sub-text{ position: absolute;
top: 63%;
left: 50%;
transform: translate(-50%, -50%);
color: white;
font-size: 4vw;
font-family: apple chancery;}

/*This is for footer*/
.footer {
background-color: #0b0c0c;
padding: 10px;
color: white;
padding-top: 70px;
padding-bottom: 100px;
padding-left: 40px;}

.footer_2{background-color: #1e1f21;
padding-top: 20px;
padding-bottom: 30px;
color: white; }

div#info{ color: #9fa1a3;}


.copy_reg{float:right;
display: inline-block;
padding-right: 10px; }

/*This is for media buttons*/
.fa {
padding: 6px;
font-size: 5px;
text-align: center;
text-decoration: none;
margin: 5px 5px;
}

.fa:hover {
opacity: 0.7;
}

.fa-facebook {
background: #3B5998;
color: white;}

.media{font-size: 20px;
padding-right: 60px;
float: right;
display: inline-block;}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Lets Save Pets</title>
<link rel="stylesheet" href="index.css" type="text/css" />
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body style=background:white>

<div class="header" id="myHeader">

<div class="topnav" id="myTopnav">
<a href="index.html" class="active">Home</a>
<a href="news.html">News</a>
<a href="gallery.html">Gallery</a>
<a href="joinus.html">Join Us</a>
<a href="aboutus.html">About</a>
</div>

</div>

<div class="text"><b>LETS&nbsp;SAVE&nbsp;PETS</b></div>
<div class="sub-text"><b>We need you in this mission!</b></div>

<div class="parallax"></div>

<div class="content" style="background-color:white;">

<h1><u>Saving a life is easier than you think.</u></h1>
<p><font size="5">
“You can do it!” Every day, we say those four magical words to people around the globe who
want to help animals in need but are unsure of their abilities. With some friendly encouragement
and guidance, you’ll be amazed at what you can accomplish.

<h2>Helping to save animals</h2>

Each of us can help bring about a time when there are No More Homeless Pets. In fact, that’s just
what it is going to take — every person reading this article committing to do just a little bit to
reach this goal. Sure, many of us think we can’t make a difference for one reason or another, but
the truth is that no matter how little time, money or experience you have, you can still save
an animal’s life. It’s easier than you think, and makes you feel good, too.
<br /> <br />
We’ve heard from so many of you who want to help but aren’t sure how, so we’re going to tell you
about simple ways that you can make a huge impact. It’s time to do all we can to save the lives of
homeless animals. They’re counting on us — and we know <b>you can do it!
</b></font></p>
</div>

<div class="footer">
<div class="media">FIND&nbsp;US&nbsp;ON<a href="https://www.facebook.com/letsavepet/" class="fa fa-facebook"></a></div>
CONTACT&nbsp;INFO<br /><br />
<div id="info"><i class="material-icons">local_phone</i> +91 7982189411<br /><br />
<i class="material-icons">local_post_office</i> letsavepet@gmail.com<br /><br />
<i class="material-icons">map</i> 1/5300-C, Street no.- 11,<br />
Balbir Nagar Ext., Shahdara,<br />
Delhi-110032, India</div>
</div>

<div class="footer_2">&nbsp;&nbsp; &copy; Letsavepet
<div class="copy_reg">All Rights Reserved&reg;</div></div>


<script>
function myFunction() {
var x = document.getElementById("myTopnav");
if (x.className === "topnav") {
x.className += " responsive";
} else {
x.className = "topnav";
}
}

window.onscroll = function() {myFunction()};

var header = document.getElementById("myHeader");
var sticky = header.offsetTop;

function myFunction() {
if (window.pageYOffset >= sticky) {
header.classList.add("sticky");
} else {
header.classList.remove("sticky");
}
}
</script>

</body>
</html>

关于html - 我的文字未随屏幕尺寸调整,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48505944/

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