When writing articles, blog posts, tutorials, magazine entries or anything else, you will often want to include some images, charts, photographs, or even videos and code snippets to illustrate your content.
That being said, you will most likely want to attach some kind of caption to these elements, and perhaps number them so your readers can keep track of your thoughts.
话虽这么说,您很可能希望对这些元素加上某种标题,并可能对其编号,以便您的读者可以跟踪您的想法。
And that’s exactly what we are going to do in today’s tutorial: combining the usage of the element with CSS counters to make your inserted elements (especially images) sexy as hell!
The element is intended to be used along with the element to mark up images, illustrations, photos, diagrams and code snippets among other things. Here is what the spec says about this element:
元素旨在与元素一起使用,以标记图像,插图,照片,图表和代码片段。 规格说明如下:
The figure element represents a unit of content, optionally with a caption, that is self-contained, that is typically referenced as a single unit from the main flow of the document, and that can be moved away from the main flow of the document without affecting the document’s meaning.
Here are a few notes regarding the figure element:
以下是有关图形元素的一些注意事项:
The element is optional
元素是可选的
You can only have one element in a element
元素中只能有一个元素
You can embed as many other elements as you want in a element
您可以在元素中嵌入任意数量的其他元素。
When dealing with an image, you can leave the alt attribute empty if you include a to prevent screen readers from reading twice the same content
处理图像时,如果包含 ,则可以将alt属性保留为空,以防止屏幕阅读器阅读两次相同的内容
For more information about the element, I recommend you this great article from HTML5Doctor. There is also this entry at Mozilla Developer Network and of course the official specification.
For example, if you want to show a snippet of code, you can do it this way with the element:
例如,如果要显示一段代码,可以使用元素以这种方式进行操作:
body { background: white; }Some illustrated code with figure
Basically, instead of adding your images this way:
基本上,不要以这种方式添加图像:
… you can do something like this:
…您可以执行以下操作:
浏览器支持(Browser support)
The is part of the “new” HTML5 elements, which are not understood by a range of old browsers including Internet Explorer 8. Since you don’t want to make your layout explode because of this tutorial, I’d recommend you include a polyfill to support these elements.
是“新” HTML5元素的一部分,包括Internet Explorer 8在内的许多旧版浏览器都无法理解 。由于您不想由于本教程而导致布局爆炸,因此建议您包括一个支持这些元素的填充。
The most known and used polyfill for HTML is html5shiv which you can embed directly from the Google CDN by adding this line into your files:
CSS Counters have to be one of the most unknown CSS properties in the whole range of properties there is. It makes automatic numbering possible exclusively through CSS, without the help of neither HTML nor JavaScript.
Pretty straight forward, isn’t it? Basically, you initialize a counter with the name you want to the value you want (mostly 0) and you tell a given selector to increment this counter at each occurrence. This counter can then be displayed using CSS generated content and the style and location can be specified with the :before and :after pseudo-elements.
The most basic implementation of a CSS counter has to be this one:
CSS计数器的最基本实现必须是以下一种:
/* 1. We initialize the counter */
body {
counter-reset: myAwesomeCounter;
}
/* 2. We tell each occurrence of this element to increment the counter */
.myAwesomeElement {
counter-increment: myAwesomeCounter;
}
/* 3. We display the value of the counter before the element */
.myAwesomeElement:before {
content: counter(myAwesomeCounter);
}
Note: I lied when I said “2 properties and 1 value”, there is also a counters() value which is almost never used. Please refer to this entry at MDN for more information about it.
Those 3 lines of CSS are enough to number our figures automagically. Isn’t that awesome?
这三行CSS足以自动为我们的数字编号。 那不是很棒吗?
包装一切 (Wrapping everything)
基础(The basics)
Now that we know how to use both the element and CSS Counters, it is time to make what we wanted to do: embellish our blog posts.
现在我们知道如何同时使用元素和CSS计数器,现在该做出我们想要做的事情了:修饰博客文章。
But before jumping into the code, wouldn’t it be cool if we could easily make floated or centered figures, just by adding a simple class? Sure, it would be. Let’s do this!
In order to horizontally center images and prevent them from breaking out of their container (the element), we need to add some rules to them (could as well be or something else).
Now the caption! We make it stand out a bit, change the typography and center it horizontally. But frankly the styling is up to you. Just remember a caption should be removed without too much hassle, so don’t write a wall of text.
If you don’t necessarily want to number your images, you can limit this to a given class on the parent element. Perhaps you’ll give your wrapper a .numbered-figures class so that it enables image numbering. Easy enough:
For those of you who do not know min-content, it is a valid value for width, min-width, max-width, height, min-height and max-height among other properties include flexbox and grid layout.
In our case, we want the figure element to be as small as possible; basically, we want it to wrap around the image. Because is a block-level element, it stretches to the width of its parent (100%). We could set it to float: left or display: inline-block to make it collapse to the widest piece of content but if the caption happens to be wider than the image we have a problem.
We could hard code the width to the figure element depending on the image, but it is inflexible and non-responsive. That’s why we introduce the min-content value. To put it simple, it tells the element to reduce its width so that the image fits inside it perfectly even if the caption has to wrap.
This value is supported by Firefox 3+ with the -moz- prefix and Chrome 18+ with the -webkit- prefix. The unprefixed version is currently not supported by any browser but might be in the future so we leave it.
Non-supportive browsers behave as expected: no width is set, the floated element wraps around the widest element, either the image or the caption.
不支持的浏览器的行为符合预期:未设置宽度,浮动的元素环绕最宽的元素(图像或标题)。
Note: there are other values similar to min-content like max-content, fit-content and available. Please refer to this entry at MDN or the working draft of CSS Intrinsic & Extrinsic Sizing Module Level 3for further information about these.
Last but not least, we need to change/remove the max-width value on images for floated figures. Either you want images to have their own size, and you need to set max-width to none, or you want to set a maximum width (which I recommend) and you define whatever you want:
.figure-right img,
.figure-left img {
max-width: 300px; /* Adjust to suit your needs */
}
小屏幕(Small screens)
To make sure floated figures don’t behave oddly on small screens, we need to override a couple of styles to make them full-width and horizontally centered. If you’re building your site using a mobile first approach, you’ll do it the other way but it doesn’t matter really.
Using this is easy as a pie. Either you want an horizontally centered figure in which case you simply have to use the .figure class. Or — most likely — you want to float the figure either on the left or on the right in which case you have to use both the .figure class and a variation class (e.g .figure-left).
That’s pretty much it guys, the only thing left to do is to implement this on your site. Please have a look at the associated demo to see what it looks like or see it live on my own site.
什么是Hessian
The Hessian binary web service protocol makes web services usable without requiring a large framework, and without learning yet another alphabet soup of protocols. Because it is a binary p
在Spark Shell上,通过创建HiveContext可以直接进行Hive操作
1. 操作Hive中已存在的表
[hadoop@hadoop bin]$ ./spark-shell
Spark assembly has been built with Hive, including Datanucleus jars on classpath
Welcom
JMS Message Delivery Reliability and Acknowledgement Patterns
http://wso2.com/library/articles/2013/01/jms-message-delivery-reliability-acknowledgement-patterns/
Transaction and redelivery in
转载请出自出处:http://eksliang.iteye.com/blog/2177567 一、游标
数据库使用游标返回find的执行结果。客户端对游标的实现通常能够对最终结果进行有效控制,从shell中定义一个游标非常简单,就是将查询结果分配给一个变量(用var声明的变量就是局部变量),便创建了一个游标,如下所示:
> var