我剛剛完成了我的個人網站,我非常努力地工作。在電腦上看起來很正常,但在手機上看起來完全沒有問題。爲什麼?這是我的第一個網站,我非常激動地在手機上看到它,只是看到它完全無法播放。爲什麼我的網站在手機(ReactJS)上看起來完全不同?
這裏是我的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/[email protected]/dist/react.js"></script>
<script src="https://unpkg.com/[email protected]/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 protected]">[email protected]</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'));
對於初學者,您的網站沒有響應。檢查更多關於它[這裏](http://stackoverflow.com/questions/32742532/how-to-build-a-responsive-website-with-reactjs)。 – vasa
@vasa啊,我明白了。我覺得這是因爲我已經實現了各種像素,導致它在手機上看起來很瘋狂。 – yabva89