【发布时间】:2017-07-14 18:48:29
【问题描述】:
我已经为现在需要转移到 Wordpress 的网站构建了前端 HTML/CSS 代码。我正在使用 html5blank 主题,因为这是为此目的而推荐的。我看过 Chris Lam 的教程,这一切似乎都很简单。 但是,我的样式表有很多问题——有些规则似乎正确应用,有些则没有,这很奇怪。根据教程,我所做的只是删除 style.css 文件中的样式代码并将其替换为我自己的。 为什么有些规则适用而不适用其他规则?我是否需要向另一个文件(function.php?)添加一些内容以允许我的样式规则起作用?
举个例子,这是我的标题和顶部部分在我的前端主页中的外观 -
这是(可怕的)Wordpress 版本 -
我已重新设置背景图片以包含 Wordpress 版本的链接 -
section#home {
height: 400px;
background: url("http://localhost:8888/wp-content/uploads/2017/07/homepagemain.jpg") center center no-repeat;
background-size: 100%;
background-position: center;
overflow: hidden;
position: relative;
}
但它似乎不想出现。
在导航栏上,我不得不根据 header.php 文件中的要求将标签替换为以下代码 -
<nav>
<?php html5blank_nav(); ?>
</nav>
仅将 php 代码包装在标签中是没有效果的。
我读过一些主题需要子/父主题,但这不应该适用于 HTML5blank 主题,因为它实际上是一个空壳。 相同的代码已传输到 style.css 文件中。我是否还必须删除 normalise.css 文件?我在前端版本中使用了 reset.css。任何援助将不胜感激。
/* GENERAL */
@import url('https://fonts.googleapis.com/css?family=Merriweather+Sans:100,200,400,700,700i,800,800i');
body {
font-family: "Merriweather Sans", sans-serif;
font-size: 16px;
line-height: 1.5;
color: #333333;
}
body {
margin: 0 auto 0 auto;
}
.container {
margin: auto;
max-width: 100%;
padding-left: 10px;
padding-right: 10px;
}
header {
background: #ffffff;
height: 100px;
top: 0;
z-index: 10;
}
.left-header { background:white; width:50%; float:left; height: 100px; }
.right-header { background:white; width:50%; float:right; height: 50px; }
.right-header-top { background: white; float: right; width: 100%; height: 100%; margin-right: 100px; }
.right-header-bottom { background: white; float: left; width: 100%; height: 100%; }
#logo {
margin-left: 60px;
margin-top: 50px;
}
nav {
float: left;
font-weight: 400;
}
nav a {
color: #000000;
text-decoration: none;
display: inline-block;
margin-top: 15px;
margin-right: 25px;
font-size: 12px;
}
div#contact {
float: right;
margin-right: 20px;
}
div#contact img {
display: inline-block;
border: 10px;
margin: 20px;
width: 30px;
height: 30px;
}
div#contact p {
display: inline-block;
margin-top: 25px;
font-size: 10px;
}
.right-header-bottom i {
height: 10px;
width: 10px;
border: 15px;
float: left;
margin-top: 15px;
margin-right: 10px;
margin-left: 10px;
}
a {
color: #000000;
text-decoration: none;
}
a:hover {
color: #000000;
}
/* HOME PAGE */
section#home {
height: 400px;
background: url(../images/homepagemain.jpg) center center no-repeat;
background-size: 100%;
background-position: center;
overflow: hidden;
position: relative;
}
#agencyimage {
position: absolute;
margin: 0;
top: 40%;
left: 50%;
transform: translate(-50%, -50%);
}
.showreel {
height: 50px;
max-width: 100%;
position: absolute;
background-color: black;
bottom: 0;
padding: 0 30px;
justify-content: space-between;
}
.showreel, .showreel > div.seemore {
display: flex;
align-items: center;
justify-content: flex-start;
flex:1;
}
.showreel, .showreel > div.seeour {
justify-content: flex-end;
flex:1;
display: flex;
align-items: center;
}
.showreel p {
font-size: 15px;
font-weight: normal;
margin: 0;
padding-left: 10px;
color: #ffffff;
}
.showreel i {
color: #ffffff;
}
.seemore {
margin-left: 30px;
}
.seeour i {
margin-right: 30px;
}
<html>
<head>
<meta charset="utf-8">
<title>Feature Media</title>
<meta name="description" content="Video technology and production">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="css/reset.css" />
<link rel="stylesheet" href="css/skeleton.css" />
<link rel="stylesheet" href="css/style.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body>
<header>
<div class="left-header">
<img src="images/Logo.png" alt="logo" id="logo" style="width:250px;height:30px;">
</div>
<div class="right-header">
<div class="right-header-top">
<div id="contact">
<img src="images/phone.png">
<p>0113 220 5265</p>
<img src="images/email.png">
<p>hello@featuremedia.co.uk</p>
</div>
</div>
<div class="right-header-bottom">
<nav>
<a href="index.html">HOME</a>
<a href="portfolio.html">PORTFOLIO</a>
<a href="business.html">PRODUCTS</a>
<a href="about.html">ABOUT</a>
<a href="contact.html">CONTACT</a>
<a href="blog.html">BLOG</a>
</nav>
<i class="fa fa-facebook" aria-hidden="true"></i>
<i class="fa fa-twitter" aria-hidden="true"></i>
<i class="fa fa-instagram" aria-hidden="true"></i>
<i class="fa fa-youtube-play" aria-hidden="true"></i>
<i class="fa fa-linkedin" aria-hidden="true"></i>
</div>
</div>
</header>
<section id="home">
<a href="agency.html"><img src="images/AGENCY-BUSINESS.png" id="agencyimage" style="width: 150px; height: 250px;"></a>
<div class="container showreel">
<div class="seemore">
<span class="fa-stack fa-lg">
<i class="fa fa-circle fa-stack-2x" style="color:#fff"></i>
<i class="fa fa-chevron-down fa-stack-1x" style="color: #000000;"></i>
</span>
<p>SEE MORE</p>
</div>
<div class="seeour">
<p>SEE OUR SHOWREEL</p>
<i class="fa fa-play-circle fa-3x" aria-hidden="true"></i>
</div>
</div>
</section>
【问题讨论】:
-
恐怕这里的变量太多了,很难得到答案......
-
@PeterFeatherstone 是的,我能理解。但是,有没有一种标准方法可以将 css 文件上传到 Wordpress 上?对于经验丰富的 WP 开发人员来说,我遗漏了什么是显而易见的吗?
-
不是真正的标准方式。如果您的 HTML 和 CSS 相同,则使用 WordPress、平面文件或任何其他框架都没关系...
-
当使用 chrome 的开发者工具检查你的页面时 - 它在哪里说它正在寻找那个背景图片?
-
@PeterFeatherstone 我在 style.css 文件的底部包含了我的骨架 css 代码 - 这会不会影响样式?