CSS - Positions

CSS Box Model

display property:

  • block:
  • inline-block
  • inline
  • none

The margin is the space around the element. The larger the margin, the more space between our element and the elements around it. We can adjust the margin to move our HTML elements closer to or farther from each other.

margin: auto;  put equal left and right margins on our element, centering it on the page

margin-top: /*some value*/

margin-right: /*some value*/

margin-bottom: /*some value*/

margin-left: /*some-value*/

one time to set: margin: 1px 2px 3px 4px;

The border is the edge of the element. It‘s what we‘ve been making visible every time we set the border property.

The padding is the spacing between the content and the border. We can adjust this value with CSS to move the border closer to or farther from the content.

The content is the actual "stuff" in the box. If we‘re talking about a <p> element, the "stuff" is the text of the paragraph.

Floating

float: right

clear: right or left or both;

position

position: absolute

When an element is set to position: absolute, it‘s then positioned in relation to the first parent element it has that doesn‘t have position: static, If there‘s no such element, the element with position: absolute gets positioned relative to <html>.

Relative positioning is more straightforward: it tells the element to move relative to where it would have landed if it just had the default static positioning.

fixed position anchors an element to browser window, If you scroll up and down, the fixed element stays put even as other elements scroll past.

时间: 2024-10-08 06:17:11

CSS - Positions的相关文章

网页设计师常用的PHOTOSHOP插件

Photoshop是网页设计师常用的一个非常重要而强大的工具,可以让网页设计师的工作高效便捷的进行,也为设计师们的天马行空提供了实际技术实现.一般我们的网页设计师设计完成后,需要将其转换制作成网页形式文件,生成HTML和CSS:然而在Photoshop中却没有这个转换高效率的功能,但万幸的是我们可以用插件来实现.Photoshop插件可以扩展我们的Photoshop基础功能,让他更加的强大和专业. 今天就为大家收集了一些对于网页设计师来说非常实用的Photoshop插件,包括:PSD转换HTML

[CSS] Build Responsive CSS Layouts with Tachyons

Building responsive css layouts is critical in any modern website. Tachyons makes this easy by designing for mobile first then enabling you to switch directions and positions of elements when the site scales up to desktop sizes. This lesson walks you

CSS常用属性2

一.边框(Border) border:复合属性.设置对象边框的特性. 取值:border: line-width | line-style | color 1)line-width:设置或检索对象边框宽度. 2)line-width:设置或检索对象边框样式. 3)color:设置或检索对象边框颜色. 示例: 这里有边框 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <ti

HTML、CSS常用技巧

一.HTML 在介绍HTML之前,我们先看一下HTML的文档树结构,主要包括哪些: (一).头部标签 1,Doctype Doctype告诉浏览器使用什么样的HTML或XHTML规范来解析HTML文档. 有和无的区别: BackCompat:标准兼容模式未开启(怪异模式.混杂模式): CSS1Compat:标准兼容模式已开启(严格模式). 这个属性会被浏览器识别并使用,但是如果你的页面没有DOCTYPE的声明,那么compatMode默认就是BackCompat,这也就是恶魔的开始,浏览器按照自

关于CSS需要知道的10件事

原文: http://dsheiko.com/weblog/10-things-to-need-to-know-about-css CSS may look as a simple language. In fact it can be simple only to use, but definitely not simple to maintain. CSS看起来是个简单的语言,实际上只是使用较为简单,但是很显然维护它并不简单. Observing that the maximum numbe

关于CSS反射倒影的研究思考

原文地址:https://css-tricks.com/state-css-reflections 译者:nzbin 友情提示:由于演示demo的兼容性,推荐火狐浏览.该文章篇幅较长,内容庞杂,有一定难度.而我本人学识有限,加之时间仓促,所翻译内容可能有不恰当及晦涩之处.欢迎大家拍砖指正. 我最近在codepen上看到了这个 加载程序,一个纯CSS制作的带有渐变反射的3D旋转竖条.它的制作方法是:为每个竖条创建一个元素,然后通过复制每一个元素来创建反射倒影,最后在反射倒影上添加渐变背景来创建渐隐

jquery + css 特效 之 一款基于jQuery/CSS3实现拼图效果的相册

今天我们要来分享一款很酷的jQuery相册插件,首先相册中的图片会以一定的角度倾斜放置在页面上,点击图片缩略图就可以展开图片,并且图片是由所有缩略图拼接而成,图片展开和收拢的动画效果也非常不错.当然图片倾斜需要CSS3支持.效果图如下: 本章主要参照了如下文章进行学习 jquery:http://www.itmmd.com/tag/jquery.html jQuery教程(31)-jQuery插件开发之全局函数插件 jQuery教程(30)-jQuery插件开发之自定义选择符 jQuery教程(

实用带多种CSS动画特效的jQuery弹出层插件hDialog.js

<!doctype html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"> <link rel=&qu

介绍css 的3D 变换(3D transform)

https://desandro.github.io/3dtransforms/docs/card-flip.html --------------------------------------------------------------------------------------------------- Card Flip We now have all the tools to start making 3D objects. Let's get started with the