div

DIV 自定义滚动条样式(二)

怎甘沉沦 提交于 2019-12-03 09:30:31
流浏览器自带的滚动条样式很丑,确实有必要美化。 滚动条从外观来看是由两部分组成:1,可以滑动的部分,我们叫它滑块2,滚动条的轨道,即滑块的轨道,一般来说滑块的颜色比轨道的颜色深。 滚动条的css样式主要有三部分组成: ::-webkit-scrollbar 定义了滚动条整体的样式; ::-webkit-scrollbar-thumb 滑块部分; ::-webkit-scrollbar-thumb 轨道部分; 下面以overflow-y:auto;为例(overflow-x:auto同) html代码: <div class="test test-1"> <div class="scrollbar"></div> </div> css代码: .test{ width: 50px; height: 200px; overflow: auto; float: left; margin: 5px; border: none; } .scrollbar{ width: 30px; height: 300px; margin: 0 auto; } .test-1::-webkit-scrollbar {/*滚动条整体样式*/ width: 10px; /*高宽分别对应横竖滚动条的尺寸*/ height: 1px; } .test-1::-webkit-scrollbar-thumb {/

css 关于ul在div里居中且平铺的问题

旧巷老猫 提交于 2019-12-03 09:28:19
今天在调整ul居中的问题时,遇到了点小困难,以前在使用ul时候,让其不是垂直的排列而是,横着排列都是使用float:left这个属性,但是呢,今天我在弄一些友情链接的时候,就出现了ul在div中居中不了的问题,就是在div中加入了style=“text-align:center;” ul也不居中,最后仔细对比了网上的,发现时用了float:left的原因,首先平铺,可以对ul的style使用display:inline,而不必使用float属性,这样之后在div上就可以使用style=“text-align:center;” 使ul列表居中显示了。 备注:此种设置方法LI将不能设置宽度,应设置display:inline-block;才可设置宽度,同时DIV设置text-align:cente;才有效 1、假设最初的的代码是这样: <div id="links" style="border:1px solid red;"> <ul> <li><a href="#">link111111</a></li> <li><a href="#">link2222</a></li> <li><a href="#">link33333</a></li> <li><a href="#">link44444</a></li> <li><a href="#">link555555</a></li> <

React练习 1 :控制div属性

江枫思渺然 提交于 2019-12-03 09:19:13
在线效果浏览 需求:5个按钮,点击后分别修改 1 个div元素的一项属性 2个组件: 父组件:App a 利用 hook useRef 获取 div元素的引用,并传递给子组件 Myinput b 数据源数组 styles,使用数组函数 map 返回一个mybtns数组,由5个Myinput子组件组成 子组件:Myinput 绑定 onClick,根据传入的 props.index来判断需设置元素的何种属性 import React,{useRef} from 'react'; import ReactDOM from 'react-dom'; import './index.css'; function Myinput(props){ const handleClick=function(){ const index=props.index; const item=props.item; const style=props.btns.current.style; switch(index){ case 0: style.width=item.width; break; case 1: style.height=item.height; break; case 2: style.background=item.background; break; case 3: style

Javascript can&#039;t find Div Element by Name

匿名 (未验证) 提交于 2019-12-03 09:14:57
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: This code surprised me yesterday and I'm curious about what was going on. If I refer to a Div element that I know is on the page in a Form, even copy/pasting the exact name, using getElementsByName the following could would not find it. var coll = document.getElementsByName("txtState"); //coll will be null If I get all the Div tags on the page and iterate through them looking at the name property I could find the correct Div element. var coll = document.getElementsByTagName("Div"); for (var i = 0; i < coll.length; i++) { var el= coll[i]; if

Fixed sidebar on the scroll stop at div

匿名 (未验证) 提交于 2019-12-03 09:13:36
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I try to make sure that a div "filter" becomes fixed when scrolling and then stop when it comes down to "outside_footer_wrapper". use the following script but can not get it to work? jsfiddle $(function() { var top = $('#filter').offset().top - parseFloat($('#filter').css('marginTop').replace(/auto/, 0)); var footTop = $('#outside_footer_wrapper').offset().top - parseFloat($('#outside_footer_wrapper').css('marginTop').replace(/auto/, 0)); var maxY = footTop - $('#filter').outerHeight(); $(window).scroll(function(evt) { var y = $(this)

DIV完美等分的CSS样式实现

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-03 09:12:10
一、问题场景 传统使用width属性配合float总是最右边出现间隙,需要实现任意个DIV的完美等分,包括横向和纵向 二、实现 父元素样式 /*盒模型*/ display: -webkit-box; display: -moz-box; display: box; /*横向or纵向*/ -webkit-box-orient: horizontal; /* 垂直是vertical */ -moz-box-orient: horizontal; /* 垂直是vertical */ box-orient: horizontal; 子元素样式 -webkit-box-flex: 1; -moz-box-flex: 1; box-flex: 1; 三、完整代码 <template> <div class="main-box"> <div class="main-box-content">1</div> <div class="main-box-content">2</div> <div class="main-box-content">3</div> </div> </template> <script> import serialport from 'serialport' export default { name: "MainPage", data: function () {

Too cumbersome change div widths with Javascript on window resize

匿名 (未验证) 提交于 2019-12-03 09:02:45
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: Is re-sizing DIVs on window-resize with Javascript too heavy for most browsers/computers? I'm doing this, because just setting widths in percentages only works in relation to the parent element. I can't seem to make it a percentage of the body, without regard to other parent elements between (on the DOM tree) the elements I would like to resize and the body. function resize_columns () { var d = getWindowSize (); var body_width = d . x ; var fch_width = body_width * . 15 ; var pnh_width = body_width * . 25 ; $ ( '.for_customer_div'

How do I center an SVG in a div?

匿名 (未验证) 提交于 2019-12-03 09:02:45
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have an SVG that I am trying to center in a div. The div has a width or 900px. The SVG has a width of 400px. The SVG has its margin-left and margin-right set to auto. Doesn't work, it just acts as if the left margin is 0 (default). Anyone know my error? 回答1: SVG is inline by default. Add display: block to it and then margin: auto will work as expected. 回答2: Above answers did not work for me. Adding the attribute preserveAspectRatio="xMidYMin" to the tag did the trick though. The viewBox attribute needs to be specified for this to work as

Load (Lazy Loading) a Div whenever the DIV gets visible for the first time

匿名 (未验证) 提交于 2019-12-03 08:59:04
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I want to enable a lazy loading for the contents of my website. Just like Jquery Image loading http://www.appelsiini.net/projects/lazyload that is valid only for images. I want to do it for the content (DIV's). Suppose we have a long page then i want to download the div as they becomes visible. I will download the content using JSON or PageMethods. But i want the code that will execute the function for loading contents. So whether we can somehow find this that div is visible only scrolling down. Means i need to use some scroll

jquery resize listener on a div

匿名 (未验证) 提交于 2019-12-03 08:59:04
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: This is the situation, I have 2 div's next to each other. One div is very dynamic in height, which basically means it can grow and shrink to accommodate for it's content. For example, this div has content that can be folded open or close, or containers that can expand to fit ajax loaded content. Now, next to this div is another one that neatly follows the height of the first one through css. Works great. But here is the question: I would like to change the content of this second div depending on its height. In other words, div 1 changes in