position

jquery find element's position

两盒软妹~` 提交于 2019-12-21 20:48:26
问题 <ul> <li>one</li> <li>element</li> <li>text</li> <li>val</li> </ul> how can i get the position in the ul of the clicked li ? 回答1: I think this will do it for you: $("li").click(function () { alert($(this).index()); }); Note that the index() function returns the index of the item in the jquery collection. If you have multiple lists on the page, make sure your selector only selects the list items that you want. 回答2: $('ul li').click(function() { alert( $(this).parent().find('li').index(this) );

DIV absolute positioning - maintain position after browser window resize

浪子不回头ぞ 提交于 2019-12-21 20:29:19
问题 I am displaying divs with position absolute. .my_label{ list-style:none; list-style-type:none; position:absolute; top:2px; left:10px; width:20px; height:20px; background-color:#FF1021; } once I re-size the browser window, all these divs stay at same position. and they're not absolute to the parent elements anymore. I want them to stay in relation with the surrounding objects. should I use position "relative" or is there another way? (also jQuery is welcome) thanks a lot 回答1: To make an

Sidebar position “semi” fixed css

我与影子孤独终老i 提交于 2019-12-21 18:30:03
问题 How do i get a fixed sidebar like the one containing the social buttons on this site: http://www.tripwiremagazine.com/2012/11/social-media-buttons-and-icon-sets.html I want my sidebar to be fixed to the top of my screen when i scroll down but on the top of the page there must be an absolute position it so that it stops following the browser as i scrool. Currently I am just using: #sidebar { position:fixed; } But this does not give it an absolute position when reaching the top of the page.

使用jQuery在屏幕上居中放置DIV

给你一囗甜甜゛ 提交于 2019-12-21 13:06:54
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 如何使用jQuery在屏幕中央设置 <div> ? #1楼 我在扩展@TonyL给出的好答案。 我要添加Math.abs()来包装值,并且还要考虑到jQuery可能处于“无冲突”模式,例如WordPress。 我建议您使用Math.abs()包装顶部和左侧的值,如下所示。 如果窗口太小,并且模式对话框的顶部有一个关闭框,则可以防止看不到关闭框的问题。 Tony的函数可能具有负值。 关于如何以负值结束的一个很好的例子是,如果您有一个大的居中对话框,但最终用户已安装了多个工具栏和/或增加了其默认字体-在这种情况下,将出现在模式对话框中的关闭框(如果在顶部)可能不可见且不可点击。 我要做的另一件事是通过缓存$(window)对象来加快速度,以便减少多余的DOM遍历,并使用集群CSS。 jQuery.fn.center = function ($) { var w = $(window); this.css({ 'position':'absolute', 'top':Math.abs(((w.height() - this.outerHeight()) / 2) + w.scrollTop()), 'left':Math.abs(((w.width() - this.outerWidth()) / 2) + w

css3重要知识点和bug解决方法

谁都会走 提交于 2019-12-21 12:32:24
1.图片向下撑大3像素问题 在一个盒子里面放一张图片,默认情况下,图片会向下撑大3像素,有以下几种解决方法: 1.1 给图片添加display:block; 1.2 给图片添加 float:left; 1.3 给图片添加 vertical-align:middle; 1.4 给他的父元素加font-size:0; 2.如何实现一张未知宽高的图片在一个盒子里面做水平垂直居中? 给父元素添加宽高,添加行高 添加 text-align:center 给图片添加 :vertical-align:center 3.元素的类型分类哪几种?各自都有什么特点? 块元素 独占一行,竖着排,能设置宽高 行内元素 默认情况下文本一行显示,不能设置宽高 行内块状元素 inline-block,既有行内元素的特点又有块状元素的特点 可变元素 添加float:left 相当于display:block 4.如何实现一个元素消失和出现? display:none display:block opcity:0; opcity:1; 5.单行文本溢出显示省略号怎么实现? 添加width; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; 6.定位的属性值有哪几个?分别有什么特点? position:absolute 绝对定位, 脱离文档流

StreamReader get and set position

江枫思渺然 提交于 2019-12-21 11:24:04
问题 i simply want to read a large CSV-File and save the Stream position in a list. After that i have to read the position from the list and set the position of the Streamreader to that char and read a line!! But after i read the first line and return the streamposition with StreamReader r = new StreamReader("test.csv"); r.readLine(); Console.WriteLine(r.BaseStream.Position); i get "177", which are the total chars in the file! (it's only a short examplefile) i didn't found anything like that here

StreamReader get and set position

陌路散爱 提交于 2019-12-21 11:23:06
问题 i simply want to read a large CSV-File and save the Stream position in a list. After that i have to read the position from the list and set the position of the Streamreader to that char and read a line!! But after i read the first line and return the streamposition with StreamReader r = new StreamReader("test.csv"); r.readLine(); Console.WriteLine(r.BaseStream.Position); i get "177", which are the total chars in the file! (it's only a short examplefile) i didn't found anything like that here

css position with percent

[亡魂溺海] 提交于 2019-12-21 09:32:54
问题 I have a problem with position divs relative in an other div. I want to make a div that is position in the horizontal middle of the screen and in this div I want to place 3 other div with the same height. But all of them should be responsive. A picture says more than words :) <div id="zwrapper"> <div id="z1" class="row"></div> <div id="z2" class="row"></div> <div id="z3" class="row"></div> </div> The blu element is the HTML html{ background: steelblue; height: 100%; width: 100%; top:0; left:0

CSS垂直居中和水平居中

China☆狼群 提交于 2019-12-21 09:24:59
前言 CSS居中一直是一个比较敏感的话题,为了以后开发的方便,楼主觉得确实需要总结一下了,总的来说,居中问题分为垂直居中和水平居中,实际上水平居中是很简单的,但垂直居中的方式和方法就千奇百怪了。 内联元素居中方案 水平居中设置: 行内元素 设置 text-align:center; Flex布局 设置display:flex;justify- content:center ;(灵活运用) 垂直居中设置: 父元素高度确定的单行文本(内联元素) 设置 height = line-height; 父元素高度确定的多行文本(内联元素) a:插入 table (插入方法和水平居中一样),然后设置 vertical-align:middle; b:先设置 display:table-cell 再设置 vertical-align:middle; 块级元素居中方案 水平居中设置: 定宽块状元素 设置 左右 margin 值为 auto; 不定宽块状元素 a:在元素外加入 table 标签(完整的,包括 table、tbody、tr、td),该元素写在 td 内,然后设置 margin 的值为 auto; b:给该元素设置 displa:inine 方法; c:父元素设置 position:relative 和 left:50%,子元素设置 position:relative 和 left:50%

Google Chrome default opening position and size [closed]

天大地大妈咪最大 提交于 2019-12-21 07:25:28
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 8 months ago . I am quite a highly OCD and lazy person and currently, I noticed that everyday late at night when I’m doing some work, I leave my Google Chrome split to the right of the screen and some document on the left side. When I open the browser in the morning, I have to manually resize the window length and width. I am