一个人为我做了一个网站,我正在努力理解它。它在这里: http://www.brilliantzenaudio.com
请注意左上方有徽标图片。我试图了解它的来源。相关代码似乎部分在header.php中,部分在app.css中。来自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>
app.css包含如下行。看看上面的php,我看到有一个类“banner”的元素,所以很明显有css代码解决(给它一个颜色,一个位置,边框和z-index)。我还看到标题标签也被赋予“banner”的“角色”。这是出于任何直接目的还是屏幕阅读器?
我们还可以看到php包含h1元素,以及'h1'元素中的'a'元素。这些东西都有CSS条目。我不清楚他们的目的是什么。首先,徽标是图像。为什么放入h1标签?我理解标签的必要性,因为徽标应该是可点击的(回到主页)。但是链接文本的内容是下一步(我不清楚如何在那里解析PHP。有什么聪明的是图像放在那里因为它是“h1.logo a”css条目中的背景。
我在下面的评论中添加了一些一般性问题。
.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;
}
答案 0 :(得分:3)
.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;
}
答案 1 :(得分:1)
虽然这并不一定是答案,因为 Veelen 的回应完美地反映了每个元素的作用,但下面是Google Chrome网络检查员的截图(或Firebug的Firefox。将鼠标悬停在任何DOM元素上,它会告诉您有关它的所有信息,点击CSS规则并动态修改任何内容。
试验它,看看事物的外观和方式感觉和它的构造。这是大多数开发人员测试和测试的方式。看看变化看起来如何,无需上传Code / Re,无论你接触到什么; Web Inspector期间更改,未保存=)