简体   繁体   English

WordPress,根主题,标题

[英]Wordpress, Roots theme, header

A guy did a website for me and I'm trying to understand it. 一个人为我建立了一个网站,我正在努力了解它。 It's here: http://www.brilliantzenaudio.com 在这里: http : //www.brilliantzenaudio.com

Note that there's a logo image at the top left. 请注意,左上方有一个徽标图像。 I'm trying to understand where this came from. 我试图了解这是从哪里来的。 The relevant code seems to be partly in header.php and partly in app.css. 相关的代码似乎部分在header.php中,部分在app.css中。 From header.php, 从header.php,

<header class="banner" role="banner">
  <div class="container">

    <div class="row">
      <div class="col-xs-12 col-lg-2">
        <h1 class="logo"><a href="<?php echo home_url(); ?>/"><?php bloginfo('name'); ?>">Brilliant Zen Audio</a></h1>
          ... stuff removed here, other items in header ...             
      </div>
    </div>
  </div>
</header>

And the app.css contains lines as follows. 并且app.css包含以下几行。 Looking at the php above, I see that there is a element of class "banner", so clearly there is css code addressing that (giving it a color, a position, border, and z-index). 查看上面的php,我发现有一个类“ banner”的元素,因此很明显有css代码来解决该问题(为它提供颜色,位置,边框和z-index)。 I also see that the header tag is also given the "role" of "banner". 我还看到header标头也被赋予了“ banner”的“角色”。 Does that serve any immediate purpose or is that for screen readers? 这样做有什么直接目的,还是对于屏幕阅读器而言?

We can also see that the php contains h1 elements, and 'a' elements within 'h1' elements. 我们还可以看到php包含h1元素,并且在'h1'元素内包含'a'元素。 CSS entries are there for those things. CSS条目就是这些东西。 I'm not clear on what their purpose is. 我不清楚他们的目的是什么。 For one thing, the logo is an image. 一方面,徽标是图像。 Why is it put in an h1 tag? 为什么将它放在h1标签中? I understand the need for the tag because the logo should be clickable (to get back to the home page). 我了解标签的必要性,因为徽标应该是可点击的(返回首页)。 But what is put as the text of the link is some next (I'm not clear on how to parse the PHP there. What's clever is that the image gets put there because it's the background in an "h1.logo a" css entry. 但是,下一步将放在链接的文本中(我不清楚如何在此处解析PHP。聪明的地方是图像被放置在那里,因为它是“ h1.logo a” css条目中的背景。

I've added some general questions in comments below. 我在下面的评论中添加了一些一般性问题。

.banner { }

header.banner {
   background:#603913;
   position:relative; // question: what does this mean and how will it effect the position of things if I start moving or changing elements?
   border-bottom:solid 1px #fff;  // question: is this bottom border important for some reason?
   z-index:9999; // what does this do?
}
h1.logo {
   margin:0;  // is there a need to define these on h1.logo?
   padding:0;
}
h1.logo a {
   display:block; // what is display:block and how does it affect appearance? How would it affect changes if I change the size or location of the logo?
   text-indent:-9999px;  // what is this?
   background:url(../img/sm-logo.png) no-repeat 0 0;
   width:101px;    // what does it mean when you set the width and height of an <a>
   height:103px;
   margin:0 auto;
}
.banner { }

header.banner {
   background:#603913;
   position:relative; // This is set, so that the position:absolute of h1.logo a will work, and is also needed in order to make the z-index work.
   border-bottom:solid 1px #fff;  // Is responsible for the white line at the bottom of the header. It 's not important, but looks nice...
   z-index:9999; // The z-index property specifies the stack order of an element. An element with greater stack order is always in front of an element with a lower stack order.
}
h1.logo {
   margin:0;  // Yes, because normally an h1 has a top and bottom margin defined, with this setting, you set it to 0.
   padding:0;
}
h1.logo a {
   display:block; // Normally an a element has inline properties. By setting this to block you can use width, margin and other properties which aren't available for inline elements
   text-indent:-9999px;  // The text-indent property specifies the indentation of the first line in a text-block.
   background:url(../img/sm-logo.png) no-repeat 0 0;
   width:101px;    // Sets the width of this a, because it is a block element.
   height:103px;
   margin:0 auto;
}

Whilst this isn't necessarily an answer as Veelen 's response hit the nail perfectly on what each element does, but below is a screenshot of Google Chrome 's Web inspector (Or Firebug for Firefox ). 尽管这不一定是答案,因为Veelen的回答完全了解每个元素的作用,但是下面是Google Chrome浏览器的Web检查器(或Firefox的 Firebug )的屏幕截图。 Hover over any DOM Element and it'll tell you everything about it, click the CSS rules and modify anything on the fly. 将鼠标悬停在任何DOM元素上,它将告诉您所有相关信息,单击CSS规则并即时修改任何内容。

Experiment with it, see how things look & feel and it's constructed. 尝试一下,看看事物的外观和感觉以及它的构造。 It's how most Developers test & see how changes would look without having to Code/Re upload, and whatever you touch & change during Web Inspector, aren't saved =) 这是大多数开发人员测试并查看更改外观的方式,而无需进行代码/重新上传,并且您在Web Inspector期间进行的任何触摸和更改都不会保存=)

Google Chrome浏览器检查器

然后

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM