absolute

Set height 100% on absolute div

梦想与她 提交于 2019-11-27 01:45:06
问题 I am facing a problem with overlaying a 100% height div . I could use position fixed to solve the cover, but that's not really what I want because you should be able to scroll down on the 'cover' > so people with lower resolutions than mine can see the entire content. Code example: HTML <body> <div>Overlay example text</div> </body> CSS body { float: left; height: 3000px; width: 100%; } body div { position: absolute; height: 100%; width: 100%; background-color: yellow; } The problem: The div

Getting absolute path of a file

拥有回忆 提交于 2019-11-27 01:16:36
How can I convert a relative path to an absolute path in C on Unix? Is there a convenient system function for this? On Windows there is a GetFullPathName function that does the job, but I didn't find something similar on Unix... Use realpath() . The realpath() function shall derive, from the pathname pointed to by file_name , an absolute pathname that names the same file, whose resolution does not involve ' . ', ' .. ', or symbolic links. The generated pathname shall be stored as a null-terminated string, up to a maximum of {PATH_MAX} bytes, in the buffer pointed to by resolved_name . If

CSS垂直居中的方法

依然范特西╮ 提交于 2019-11-27 00:39:01
方法1:display:flex+align-items 只需要给父元素设置属性 1 <style> 2 .box { 3 position: absolute; 4 width: 100px; 5 height: 100px; 6 border: 1px solid red; 7 8 display: flex; 9 justify-content:center; 10 align-items:center; 11 } 12 </style> 13 <div class="box"> 14 <span>center</span> 15 </div> 方法2:绝对定位和负边距 top、margin-top的区别: 1、top、bottom、left、right是绝对定位,必须设置position为absolute。 margin一系列设置是相对定位。注意:如果用top等,而position未设置为absolute,那设置是不起作用的。 2、top这些在绝对定位的前提下,这个绝对定位,是相对body 或者 position:relative的父级元素的绝对定位。margin的相对定位,是指相对相邻元素的定位。 1 .box{ 2 position: relative; 3 width: 200px; 4 height: 200px; 5 border: 1px solid red;

IE7 relative/absolute positioning bug with dynamically modified page content

这一生的挚爱 提交于 2019-11-27 00:31:20
I was wondering if there's anyone having an idea how to tackle with the following problem in IE7: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>IE7 absolute positioning bug</title> <style type="text/css"> #panel { position: relative; border: solid 1px black; } #spacer { height: 100px; } #footer { position: absolute; bottom: 0px; } </style> <script type="text/javascript"> function toggle() { var spacer = document.getElementById("spacer"); var style = "block"; if

原生JS实现书本立体特效

落爺英雄遲暮 提交于 2019-11-26 22:29:33
给大家分享一个原生JS实现的书本立体特效,效果如下: 实现这个特效需要的三张图片如下: 第一张图:0.jpg 第二张图 1.jpg 第三张图:3.jpg 实现代码如下,欢迎大家复制粘贴。 <!doctype html> <html> <head> <meta charset="utf-8"> <title>原生JS实现书本立体特效</title> <style type="text/css"> * { margin: 0; padding: 0; list-style: none; } #book { width: 290px; height: 400px; position: absolute; left: 50%; top: 50%; margin: -200px 0 0 -145px; background: black; transform-style: preserve-3d; } #book .page { position: absolute; width: 100%; height: 100%; background: #ccc; } #book .topNode { position: absolute; width: 100%; height: 100%; background: url(images/2.jpg); background-size: 290px

absolute position affects width?

心不动则不痛 提交于 2019-11-26 21:30:58
问题 I am new to css. I am wondering why when I change the positioning of the div element to absolute, the width of the div element changes? Tried it out in Chrome v25.0.1364.172m and IE9, both have the same outcome. Simple example: <!doctype html/> <html> <head> <title>test</title> <style> div { position:relative; border-width: 1px; border-style: solid; border-color: black; } </style> </head> <body> <div>test</div> </body> </html> 回答1: Because absolutely positioned elements do not behave as block

CSS3之太阳系动画效果

梦想与她 提交于 2019-11-26 19:52:13
效果如下: 代码如下: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> <style type="text/css"> body{ background: #000; } .sun{ width: 100px; height: 100px; position: absolute; top: 50%; left: 50%; margin-left: -50px; margin-top: -50px; /*保证居中*/ transform: translate(-50%;-50%); background: yellow; border-radius: 50%; box-shadow: 0 0 30px 3px gold; } .earth{ width: 350px; height: 350px; position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); border:1px solid #ccc; border-radius: 50%; /*animation: whirl 5s linear infinite;*/ } .earth::before{ content: ""; width: 40px;

html+ccs3太阳系行星运转动画

寵の児 提交于 2019-11-26 19:51:45
做一个太阳系八大行星的运转动画,不包括行星的卫星,所有行星围绕太阳公转,行星采用纯色,暂时没有自转。 效果静态图: 动画中包括:太阳及各行星,运行轨道,行星公转动画。 先画好草图,设计好大小和位置,根据公转周期计算好动画执行的时间。 html的结构: 一个class为solarsys的div,作为太阳系容器元素,该div的position为relative。 行星轨道和行星都用div,position为absolute。 容器用relative和内部元素采用absolute的定位方式,比较简单的能实现效果,缺点就是大小是固定的。 <div class="solarsys"> <!--太阳--> <div class='sun'></div> <!--水星轨道--> <div class='mercuryOrbit'></div> <!--水星--> <div class='mercury'></div> <!--金星轨道--> <div class='venusOrbit'></div> <!--金星--> <div class='venus'></div> <!--地球轨道--> <div class='earthOrbit'></div> <!--地球--> <div class='earth'></div> <!--火星轨道--> <div class='marsOrbit'

css浮动与定位

瘦欲@ 提交于 2019-11-26 18:23:35
CSS系列:CSS中盒子的浮动与定位 1. 盒子的浮动   在标准流中,一个块级元素在水平方向会自动伸展,知道包含它的元素的边接;而在竖直方向与相邻元素依次排列,不能并排。   CSS中float属性,默认为none。将float属性的值设置为left或right,元素就会向其父元素的左侧或右侧靠紧。同时默认情况下,盒子的宽度不再伸展,而是根据盒子里面的内容的宽度来决定。 float: left;   可以使用clear来清除浮动: clear: left | right | both; 2. 盒子的定位   在CSS中有一个position属性,用来进行定位操作。position属性可以设置为4个属性值之一:   ◊ static:默认的属性值,该盒子按照标准流(包括浮动方式)进行布局;   ◊ relative:相对定位,使用相对定位的盒子的位置常以标准流的排版方式为基础,然后使盒子相对于它在原本的标准位置偏移指定的距离。相对定位的盒子仍在标准流中,它后面的盒子仍以标准流方式对待它。   ◊ absolute:绝对定位,盒子的位置以它的包含框为基准进行偏移。绝对定位的盒子从标准流中脱离。它对其后的相邻盒子的定位没有影响,其他的盒子就好像这个盒子不存在一样。   ◊ fixed:固定定位,它和绝对定位类似,只是以浏览器窗口为基准进行定位,当拖动浏览器的滚动条时

浮动与定位

送分小仙女□ 提交于 2019-11-26 18:23:18
http://www.w3cplus.com/css/advanced-html-css-lesson2-detailed-css-positioning.html 任务四:定位和居中问题 HTML 和 CSS 高级指南之二--定位详解 原文链接 包含浮动 当元素浮动时,一个元素的位置依赖于放置在他周边的其他元素。 浮动问题:一个父元素包含了多个浮动的子元素。 浮动元素不会影响父元素的宽度。这样做会让父元素塌陷,从而使父元素的高度为"0",以及忽略其它的属性。 嵌套的元素不会正确的排列,也会有错误的样式出现。 clear:both 在容器结束标签前添加一个空标签,在空标签上直接设置样式 clear:both 缺点:不太适合语义化,容易造成页面上空标签迅速堆积,页面中没有上下文内容。 overflow 技巧 在具有浮动元素的父容器中设置 overflow 的属性值为 auto 注意: IE6 里父元素需设置 width 和 height IE 会添加滚动条 > 最好直接使用 =overflow:hidden; 优点:父容器就会有一个高度存在 缺点: 子元素会被限制在父元素内 不同的浏览器对 overflow 属性解析不一样 clearfix 技巧 clearfix 技巧是基于父元素上使用 :before 和 :after 两个伪类。 :before