- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
问题
我是 LESS 的新手,我们刚刚在我的中级 CSS 和预处理器类(class)中学习了一些关于参数混合的基础知识。我正在我的元素网站上工作,并且喜欢 LESS 可以做的事情,但它并不总是像我想要的那样工作。
例如,在第 143 行附近,我正在设置导航背景颜色,如下所示:
background-color: lighten(@color5, 50%);
lighten()
功能本身正在工作。
color: lighten(@color5, 75%);
#ffffff
)。我仔细检查以确保颜色不仅仅是一种超浅的紫色阴影——不。它是白色的。
spin()
将链接悬停颜色设置为不同的色调。方法。但是,它也不起作用,我的悬停颜色被翻译为白色。没有意义。
/*
Assignment: CAS 215 - Module 8 Lecture Assignment
File Name: style.less
Date: 11/17/16
Programmer: Eric Hepperle
*/
@import 'palette.less';
@import 'mixins.less';
/* /END PARAMETRIC MIXINS */
/* MOBILE STYLESHEET ------------------------- */
/* UNIVERSAL SELECTOR */
* {
box-sizing: border-box;
}
/* BODY */
body {
font-family: "Open Sans", sans-serif;
font-size: 16px;
line-height: 1.5em;
background-color: @lightColor;
color: @darkColor;
a {
&:link {
color: @color5;
font-weight: bold;
}
&:visited {
color: @color4;
font-weight: normal;
}
&:hover {
/* nothing yet */
}
}
}
/* SECTION SPACING */
main, header, footer, nav {
padding: 1em;
}
/* LISTS */
ul {
list-style-type: disc;
list-style-position: inside;
padding-left: 1em;
text-indent: -1em;
}
li {
line-height: 1.5em;
}
/* INLINE TEXT ELEMENTS */
em {
font-style: italic;
}
p {
margin: 1em 0em;
.fontProperties(@darkColor; "Tahoma"; 1em; 1.2em; normal);
}
/* HEADINGS */
h1, h2, h3, h4, h5, h6 {
margin: 1em 0em;
}
h1 {
.headingFontAttributes(@color5; 1.8em);
}
h2 {
.headingFontAttributes(@color5; 1.4em);
}
h3 {
.headingFontAttributes(@color5; 1.1em);
}
h4 {
.headingFontAttributes(spin(@color5, 123); .9em);
}
h5 {
.headingFontAttributes(spin(@color5, 123); .85em);
}
h6 {
.headingFontAttributes(spin(@color5, 123); .75em);
}
/* BLOCK ELEMENTS */
pre {
font-family: "Courier New", monospace;
white-space: pre-wrap;
.fancyBox(.3em; .3em; .3em; @darkColor);
background-color: lighten(@color5, 50%);
padding: 1.2em 0 0 0;
border: solid 1px @color5;
font-size: .8em;
white-space: pre;
overflow-x: scroll;
}
/* HEADER */
header {
background-color: @color5;
h1 {
color: @color1;
margin: .2em;
text-align: center;
}
}
/* NAV */
nav {
text-align: center;
background-color: lighten(@color5, 50%);
width: auto;
display: block;
padding: 0;
margin: 0;
ul {
margin: 0;
padding: 0;
list-style: none;
li {
width: auto;
a {
text-decoration: none;
display: block;
padding: .4em 0;
border-bottom: solid 1px black;
&:link {
color: lighten(@color5, 75%);
}
&:focus {
background-color: @color2;
}
}
}
}
}
/* MAIN */
main {
background-color: @color6;
}
/* FOOTER */
footer {
background-color: lighten(@color5, 30%);
color: @lightColor;
border-top: .6em solid @color5;
/*border-bottom: .2em solid @color5;*/
a {
&:link {
color: @color1;
}
&:visited {
color: @color6;
}
}
h2,h3 {
color: darken(@color5, 10%);
}
}
/*
TABLET STYLESHEET
The following CSS affects all screen sizes larger than 480 pixels wide.
*/
@media only screen and (min-width: 481px) {
body {
font-size: 14px;
}
pre {
font-family: "Courier New", monospace;
white-space: pre-wrap;
.fancyBox(.3em; .3em; .3em; @darkColor);
padding: 1.2em;
border: solid 1px @color5;
font-size: 1em;
overflow-x: hidden;
}
}
/*
DESKTOP STYLESHEET
The following CSS affects all screen sizes larger than 1024 pixels wide.
*/
@media only screen and (min-width: 1025px) {
header, main, footer {
padding: 2em;
}
nav {
text-align: left;
background-color: lighten(@color5, 50%);
/*width: auto;*/
display: block;
padding: 1em;
padding-left: 2em;
margin: 0;
ul {
margin: 0;
padding: 0;
list-style: none;
display: inline;
padding-left: 1em;
text-indent: -1em;
li {
width: auto;
margin: 0;
padding: 0;
padding-bottom: 0;
display: inline-block;
margin-right: 3em;
a {
text-decoration: none;
display: block;
padding: 0;
border: none;
&:link {
color: lighten(@color5, 75%);
}
&:visited {
color: lighten(@color5, 75%);
}
&:hover {
color: spin(lighten(@color5, 75%),123);
}
&:focus {
background-color: @color2;
}
}
}
}
}
header {
h1 {
margin: .3em;
text-align: inherit;
}
}
}
<link href="http://erichepperle.com/in-progress/pcc/cas215/project/css/grid.css" rel="stylesheet"/>
<link href="http://erichepperle.com/in-progress/pcc/cas215/project/css/generic.css" rel="stylesheet"/>
<link href="http://erichepperle.com/in-progress/pcc/cas215/project/css/reset.css" rel="stylesheet"/>
<!DOCTYPE html>
<!--
File Name: project.html
Date: 11/17/16
Programmer: Eric Hepperle
-->
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="UTF-8">
<meta name="author" content="Eric Hepperle">
<title>CAS215 Project</title>
<link href="http://fonts.googleapis.com/css?family=Open+Sans"
rel="stylesheet" type="text/css">
<link href="css/reset.css" rel="stylesheet" type="text/css">
<link href="css/generic.css" rel="stylesheet" type="text/css">
<link href="css/grid.css" rel="stylesheet" type="text/css">
<link href="css/style.css" rel="stylesheet" type="text/css">
</head>
<body>
<nav>
<ul>
<li><a href="#intro">Intro</a></li>
<li><a href="#mobile">Mobile First</a></li>
<li><a href="#features">Features</a></li>
<li><a href="#links">Links</a></li>
</ul>
</nav>
<header>
<h1>CAS215 Project</h1>
</header>
<main>
<img src="images/startup-photos.jpg" alt="Image of a designer with a wireframe." title="Image of a designer with a wireframe">
<section id="intro">
<h2>Responsive Web Design</h2>
<p><em>Responsive web design</em> is a new design philosophy that is
different from fixed design. In responsive web design, page layouts
adjust according to the size of the end user's display; in fixed
design, sizes of fonts, box elements and images remain unchanged.</p>
<p>In the past, only desktop and laptop computers were used to surf
the web. It was a given that screen resolutions would be 1024 pixels
wide or higher. Fixed grid CSS frameworks such as
<a href="http://960.gs/">960 Grid System</a> were used to design
pages that were laid out in even columns on a fixed-width grid,
usually centered on the screen. As mobile devices began to hit the
market, it became necessary to create web pages that would work on
many devices and resolutions. As the number of devices grows
(watches that surf the web are on the horizon), the more important
it will be to write responsive sites.</p>
</section>
<section id="mobile">
<img src="images/hand-holding-mobile-phone.jpg" alt="Hand holding a mobile phone." title="Hand holding a mobile phone.">
<h2>Mobile First Design</h2>
<p><em>Mobile first design</em> is the next step in responsive web
design. In mobile first design, the primary CSS is written for mobile.
Then, the cascade later contains media queries that add more code for
larger device resolutions.</p>
<h3>Better mobile first web design</h3>
<p>Some designers write their CSS media queries so that they only
affect resolutions that are between two specific break points:</p>
<pre>
h3 {
font-size: 1.75em;
}
@media (min-width: 321px) and (max-width: 480px) {
h3 {
font-size: 2em;
}
}
</pre>
<p>This approach is severely limiting. What if there was CSS code
that is useful for <em>all</em> resolutions above 320 pixels,
including those 480 pixels and above? Writing media queries in this
way means that some code will need to be redeclared later.</p>
<p>We will try a different approach. Our media queries will
gradually add to the style of the page the larger the resolution
goes, like this:</p>
<pre>
h3 {
font-size: 1.75em;
}
@media (min-width: 321px) {
h3 {
font-size: 2em;
}
}
</pre>
<p>See the difference? If an h3 size of 2em happens to work in every
browser width above 320 pixels, we're in good shape.</p>
</section>
<section id="features" class="section group">
<div class="col span_4_of_12">
<img src="images/apple-iphone-books-desk.jpg" alt="Mobile phone and programming book by laptop on desk." title="Mobile phone and programming book by laptop on desk.">
<h3>Features of Fixed Design</h3>
<ul>
<li>A fixed page width in pixels, often centered in the
browser window.</li>
<li>Images are set at fixed widths.</li>
<li>Font sizes are set at fixed pixel or point sizes.</li>
</ul>
</div>
<div class="col span_4_of_12">
<img src="images/html-code.jpg" alt="Colored HTML code on a black computer screen." title="Colored HTML code on a black computer screen.">
<h3>Features of Responsive Design</h3>
<ul>
<li>Page and box element widths are set in percentages.</li>
<li>Image widths are set with percentages, often at 100% to
fill available width.</li>
<li>Font sizes are set with em sizes, so that they are sized
relative to the parent element's font size.</li>
<li>The primary style sheet is for desktop devices, and media
queries are used toward the end of the cascade to account
for mobile devices.</li>
</ul>
</div>
<div class="col span_4_of_12">
<img src="images/laptop-mobile-phone.jpg" alt="Laptop and mobile phone." title="Laptop and mobile phone.">
<h3>Features of Mobile First Design</h3>
<ul>
<li>The primary style sheet is for mobile devices, and media
queries are used toward the end of the cascade for tablet,
then desktop devices.</li>
<li>As a result of this change, web site interfaces are
simpler and their design is much cleaner. There is far
less CSS to write.</li>
</ul>
</div>
</section>
</main>
<footer>
<h2>External Links</h2>
<section id="links" class="section group">
<div class="col span_4_of_12">
<img src="images/responsive-design-wikimedia-740x490.png" alt="Graphic showing the same layout on various devices." title="Graphic showing the same layout on various devices.">
<h3>Responsive Design</h3>
<ul>
<li><a href="http://abookapart.com/products/responsive-web-design"
target="_blank">Ethan Marcotte</a></li>
<li><a href="https://en.wikipedia.org/wiki/Responsive_web_design"
target="_blank">Wikipedia</a></li>
</ul>
</div>
<div class="col span_4_of_12">
<img src="images/eh-mobile-first-design-740x490.png" alt="Graphic showing a mobile phone and a tablet pc." title="Graphic showing a mobile phone and a tablet pc.">
<h3>Mobile First Design</h3>
<ul>
<li><a href="https://codemyviews.com/blog/mobilefirst"
target="_blank">Opinion Piece on mobile first design</a></li>
<li><a href="http://www.sitepoint.com/making-case-mobile-first-designs"
target="_blank">Making a case for mobile first design</a></li>
</ul>
</div>
<div class="col span_4_of_12">
<img src="images/mobile-first-responsive-resources.png" alt="Graphic showing various resources including a computer, browsers icons, and books." title="Graphic showing various resources including a computer, browsers icons, and books.">
<h3>General Resources</h3>
<ul>
<li><a href="http://www.smashingmagazine.com"
target="_blank">Smashing Magazine</a></li>
<li><a href="https://css-tricks.com/"
target="_blank">CSS Tricks</a></li>
<li><a href="http://www.usability.gov/"
target="_blank">usability.gov</a></li>
</ul>
</div>
</section><!-- END links section -->
</footer>
</body>
<!--
NOTES:
10/31/16 - * Created file from Ch. 4 project.
* Changing footer colors
* Note: temporarily disabled reset styles
-->
</html>
@color1: #fcffc5; /* cream */
@color2: #ffc759; /* orange */
@color3: #ff8f5a; /* salmon/papaya */
@color4: #902d59; /* maroon */
@color5: #5e3e67; /* dark purple */
@color6: #f5f5dc; /* beige */
@darkColor: #000000;
@lightColor: #ffffff;
/* PARAMETRIC MIXINS */
.headingFontAttributes(@fontColor; @fontSize) {
color: @fontColor;
font-size: @fontSize;
font-weight: bold;
margin-top: @fontSize;
margin-bottom: @fontSize /2;
text-transform: uppercase;
}
.fontProperties(@fontColor; @fontFamily; @fontSize; @lineHeight; @fontWeight){
color: @fontColor;
font-family: @fontFamily;
font-size: @fontSize;
font-weight: @fontWeight;
line-height: @lineHeight;
}
.fancyBox(@borderRadius; @shadowOffset; @shadowSize; @shadowColor) {
border-radius: @borderRadius;
box-shadow: @shadowOffset @shadowOffset @shadowSize @shadowColor;
}
最佳答案
您的代码(或)Less 编译器生成的输出都没有问题。这更多的是一个理解问题。lighten()
函数增加 HSL 空间中颜色的亮度。您尝试变亮的颜色是 #5e3e67
其亮度值为32.35294118%。 (您可以使用 Less 编译器的内置 lightness()
函数找到它)。
以下是 Less website 的摘录:
Increase the lightness of a color in the HSL color space by an absolute amount.
lighten()
中设置百分比(数量)值时粗略大于 67.65% 时,得到的亮度值将是 100% 或更高,等于
#fff
.
#demo {
color: lighten(#5e3e67, 67%);
}
#demo2 {
color: lighten(#5e3e67, 50%);
}
#demo3 {
color: lighten(#5e3e67, 33%);
}
#demo {
color: #fefdfe;
}
#demo2 {
color: #d8c7dd;
}
#demo3 {
color: #b391bd;
}
spin()
代码中的函数也是相同的原因。没关系
hue
旋转(
spin()
函数所做的),白色将保持白色。由于
lighten()
函数的输出是白色的,
spin()
的输出也只会是白色的。
关于css - 减少变亮、变暗和旋转有时只起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40681986/
今天有小伙伴给我留言问到,try{...}catch(){...}是什么意思?它用来干什么? 简单的说 他们是用来捕获异常的 下面我们通过一个例子来详细讲解下
我正在努力提高网站的可访问性,但我不知道如何在页脚中标记社交媒体链接列表。这些链接指向我在 facecook、twitter 等上的帐户。我不想用 role="navigation" 标记这些链接,因
说现在是 6 点,我有一个 Timer 并在 10 点安排了一个 TimerTask。之后,System DateTime 被其他服务(例如 ntp)调整为 9 点钟。我仍然希望我的 TimerTas
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
我就废话不多说了,大家还是直接看代码吧~ ? 1
Maven系列1 1.什么是Maven? Maven是一个项目管理工具,它包含了一个对象模型。一组标准集合,一个依赖管理系统。和用来运行定义在生命周期阶段中插件目标和逻辑。 核心功能 Mav
我是一名优秀的程序员,十分优秀!