gpt4 book ai didi

javascript - 为什么我的网站在手机(ReactJS)上看起来完全不同?

转载 作者:太空宇宙 更新时间:2023-11-03 20:30:57 25 4
gpt4 key购买 nike

我刚刚完成了我非常努力的个人网站。在电脑上看起来很正常,但在手机上,它看起来完全不正常。为什么?这是我的第一个网站,我非常兴奋地在手机上看到它,结果发现它完全困惑了。

这是我的 index.html

<!DOCTYPE html>
<html>

<head>
<title>Website</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

<link rel="stylesheet" href="index.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://unpkg.com/react@15/dist/react.js"></script>
<script src="https://unpkg.com/react-dom@15/dist/react-dom.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.6.16/browser.js"></script>
</head>

<body>
<div id="firstBar"></div>

<script type="text/babel" src="index.js"></script>

</body>

</html>

这是我的 index.css 文件:

html {
text-align: center;
}
.container {
margin-right: 10px;
}

.portfolio {
text-align: center;
}

.about {
text-align: center;
}

.contact {
text-align: center;
}

.fullName {
float: left;
}

.myPic {
margin-left: -499px;
height: 1051px;
}

.scrollTo {
margin: inherit;
}

.number {
font-size: 89px;
}

.email {
font-size: 70px;
}

.githubIcon {
font-size: 60px;
}

.masterPv:hover .pvPic {
opacity: 0.3;
}

.masterPv:hover .middlePv {
opacity: 1;
}

.masterWFAFA:hover .WFAFAPic {
opacity: 0.3;
}

.masterWFAFA:hover .middleWFAFA {
opacity: 1;
}

.masterHP:hover .HPPic {
opacity: 0.3;
}

.masterHP:hover .middleHP {
opacity: 1;
}

.scrollToAbout {
text-align: center;
}

.masterPv {
position: relative;
width: 50%;
}

.pvPic {
opacity: 1;
display: block;
width: 400px;
height: auto;
transition: .5s ease;
backface-visibility: hidden;
}

.middlePv {
transition: .5s ease;
opacity: 0;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
}

.pvText {
background-color: #4CAF50;
color: white;
font-size: 16px;

margin-right: 139px;
}

.masterWFAFA {
position: relative;
width: 50%;
text-align: center;


/*top: -203px;*/


}

.WFAFAPic {
opacity: 1;
display: block;
width: 400px;
height: auto;
transition: .5s ease;
backface-visibility: hidden;
}

.middleWFAFA {
transition: .5s ease;
opacity: 0;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
}

.WFAFAText {
background-color: #4CAF50;
color: white;
font-size: 16px;
padding: 16px 32px;
margin-right: 139px;
}

.masterHP {
position: relative;
width: 50%;
margin-left: 640px;
bottom: 409px;
}

.HPPic {
opacity: 1;
display: block;
width: 400px;
height: auto;
transition: .5s ease;
backface-visibility: hidden;
}

.middleHP {
transition: .5s ease;
opacity: 0;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
}

.HPText {
background-color: #4CAF50;
color: white;
font-size: 16px;
padding: 16px 32px;
margin-right: 139px;
}

.mainPic {
border-width: 2px;
width: 1100px;
text-align: center;
overflow:hidden;
}

code {
text-align: center;
}

.wrapper {
background-color: rgb(134,321,342);
}

div {
text-align: center;
margin-right: 31px;
}

这是我的 index.js 文件:

var Website = React.createClass({

scrolling: function() {
$('html,body').animate({
scrollTop: $(".scrollToPortfolio").offset().top
},'slow');
},

scrollToAbout: function() {
$('html,body').animate({
scrollTop: $(".scrollToAbout").offset().top
},'slow');
},

scrollToContact: function() {
$('html,body').animate({
scrollTop: $(".scrollToContact").offset().top
},'slow')
},

render: function() {

return(

<div className="container">
<kbd className="fullName">my name</kbd>
<button onClick={this.scrolling} type="button" className="btn btn-primary portfolio">Portfolio</button>
<button onClick={this.scrollToAbout} type="button" className="btn btn-primary about">About</button>
<button onClick={this.scrollToContact}type="button" className="btn btn-primary contact">Contact</button>

<div className="mainPic">
<img src={"./pictures/skyline.jpg"}></img>
</div>

<div className="scrollToPortfolio">
<h2><u>Portfolio</u></h2>
<div className="masterPv">
<a href="http://piccolovillaggio.com/">
<img src={"./pictures/portfolioPic1.png"} className="pvPic img-rounded"></img>
</a>
<div className="middlePv">
<div className="pvText">Menu for catering company.</div>
</div>
</div>

<div className="masterWFAFA">
<img src={"./pictures/WFAFA.png"} className="WFAFAPic img-rounded"></img>
<div className="middleWFAFA">
<div className="WFAFAText">Worlds first automated financial advisor.</div>
</div>
</div>

<div className="masterHP">
<a href="http://www.ashikul.com/hunts-point/">
<img src={"./pictures/HP.png"} className="HPPic img-rounded"></img>
</a>
<div className="middleHP">
<div className="HPText">Hunts Point Seaport and Shipyard LLC company website.</div>
</div>
</div>

</div>

<div className="scrollToAbout jumbotron">
<h2><u>About</u></h2>
<h2>Text Text Text Text</h2>
</div>


<div className="scrollToContact jumbotron">
<h2><u>Contact</u></h2>
<h1 className="number">3333333333</h1>
<strong className="email"><a href="mailto:email@yahoo.com">email@yahoo.com</a></strong>
<p>
<a href="#" className="btn btn-social-icon btn-lg btn-github githubIcon ">
<span className="fa fa-github"></span>
</a>
</p>
</div>

<div className="wrapper"></div>
<span>© 2017-2018 <b>my name</b></span>
</div>
);
}
});

ReactDOM.render(<Website/>, document.getElementById('firstBar'));

最佳答案

简单的回答是因为您的网站没有响应

首先,我会将此视为您的第一个完整元素,并且您是网页设计新手。您的问题概括地说是您的网站没有响应。要做到这一点,有多种方法可以帮助您使用简单的谷歌搜索响应式网页设计。

为了帮助您进行搜索,您可以搜索用于响应式设计的插件,例如 bootstrap 或阅读 css media queries

如果我们要回答您的问题,那就是为您创建另一个网站,这不是 SO 的目的。

确保您阅读了响应式设计

希望对你有帮助

关于javascript - 为什么我的网站在手机(ReactJS)上看起来完全不同?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42239078/

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