CSS - 将样式表转移到Wordpress主题

时间:2017-07-13 15:07:50

标签: html css wordpress html5

我为现在需要转移到Wordpress的网站构建了前端HTML / CSS代码。我使用的是html5blank主题,因为这是出于此目的而推荐的。我已经看过Chris Lam的教程了,这看起来很简单。 但是,我的样式表遇到了很多问题 - 有些规则似乎正确应用,而有些则不是很奇怪。根据教程,我所做的就是删除style.css文件中的样式代码并将其替换为我自己的样式代码。 为什么有些规则适用而其他规则不适用?我是否需要在另一个文件(function.php?)中添加一些内容才能使我的样式规则有效?

举个例子,这是我的标题和顶部在我的前端主页中的显示方式 -

Front-end version

这是(可怕的)Wordpress版本 -

Wordpress version

我重新设置了背景图片以包含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作为前端版本。任何援助将不胜感激。

&#13;
&#13;
/* 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;
}
&#13;
<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>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:2)

当您的样式表未正确添加到您的主页时,就会发生这种情况。

您正在提供此路径,但这不包括样式表,因为路径不正确。

<link rel="stylesheet" href="css/reset.css" />

尝试在 css 目录

之前添加此代码
<?php bloginfo('stylesheet_directory')?>

所以,就像那样

<link rel="stylesheet" href="<?php bloginfo('stylesheet_directory')?>/css/reset.css" />

它将提供站点的基本URL,因此此代码变为 www.xyz.com/css/"您的css文件&#34;

为css的所有链接属性执行此操作,并确保所有css文件都放在该css文件夹中。