div

DIV横向布局的几种方法

£可爱£侵袭症+ 提交于 2019-12-21 22:01:01
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 1.使用display: inline;将块级元素转变为行内元素: CSS .item-test{ border: 1px solid black; padding: 7px; cursor: pointer; /*display: table-cell;*/ /*float: left;*/ width: 12px; height:214px; display: inline; } HTML <div class="item-test"> <img style="" src="../Public/images/t1.png"> </div> 缺点:虽然可以做到横向布局,但是不能设置宽度和高度,padding和margin也是没有用,如果需要border就更加不堪入目: 而且,一旦你在使用了display:inline;的元素内添加块级元素,display:inline就会失效,变回块级元素的效果。 2. 使用display: table-cell;模拟table的元素: 这种方法比第一种方法要好很多,可以调是高度和宽度,padding也可以用,但是不能用margin(想想也明白,对td(table-cell就是模拟td)使用margin本来就不行) .item-test{ border: 1px solid

让上下两个DIV块之间有一定距离或没有距离

浪子不回头ぞ 提交于 2019-12-21 17:58:07
1、若想上下DIV块之间距离,只需设定: 在CSS里设置DIV标签各属性参数为0 div{margin:0;border:0;padding:0;} 这里就设置了DIV标签CSS属性相当于初始化了 DIV标签 CSS属性,这里设置 margin外边距 为0;边框 border 属性为0和内补白也为0;这样相当于就初始化了DIV之间距各属性距离为0,这样就不会造成DIV直接有一定的距离。 2、如果想上下两个DIV间有距离的话,只需设定div中的margin属性即可,本例中div属性对全局DIV块都适用,代码如下: <!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"><style type="text/css"><!--设置DIV块的边界为5px-->div{margin:5px;border:0;padding:0;}#Box1{ width:200px; height:72px; background-color:#666;}#Box2{ width:200px; height:72px; background

使用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

css实现左边div自适应宽度,右边宽度适应左边

时光总嘲笑我的痴心妄想 提交于 2019-12-20 08:36:41
利用bfc:右边盒子触发bfc,使其不与浮动盒子区域重叠,因此会重新计算宽度。 1 <style> 2 .box{ width: 900px; margin: 0 auto; background-color: #eee; } 3 .left{ min-width: 200px; float: left; background-color: yellow; height: 60px;} 4 .bfc { background-color: green; } 5 .right{ display: inline-block; margin-left: 20px; background-color: red; height: 60px;} 6 </style> 7 <div class="box"> 8 <div class="left"> 9 我是自适应宽度盒子,min-width:200px 10 </div> 11 <div class="bfc"> 12 <div class="right"> 13 我是自适应宽度,铺满剩下宽度 14 </div> 15 </div> 16 </div> 效果如图 补充一下:   BFC翻译过来是块级格式化上下文,和haslayout比较相似,但haslayout是旧版本IE下的一个专有属性,表示元素自己对自身的内容进行组织和计算

Codeforces Round #319 (Div. 2)

北战南征 提交于 2019-12-20 07:19:46
A: A. Multiplication Table time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Let's consider a table consisting of n rows and n columns. The cell located at the intersection of i -th row and j -th column contains number i  ×  j . The rows and columns are numbered starting from 1. You are given a positive integer x . Your task is to count the number of cells in a table that contain number x . Input The single line contains numbers n and x ( 1 ≤  n  ≤ 10 5, 1 ≤  x  ≤ 10 9) — the size of the table and the number that we are looking for in

设置DIV根据内容自动调整高度的三个方法

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-20 00:04:29
Div即父容器在Firefox、Chrome、Safari中不会根据内容自动调节高度,我们看下面的HTML代码: <divid="main"><divid="content"></div></div> 当Content内容很多时,即使main设置了高度100%或auto。在除IE外的其他浏览器中还是不能完好的自动伸展。也就是说,内容的高度容器main的高度还是没有自动撑开。 我们有三种方法可以解决这个问题。 一,增加一个清除浮动,让父容器知道高度。请注意,清除浮动的容器中有一个空格。Html代码如下: <divid="main"><divid="content"></div><divstyle="font: 0px/0px sans-serif;clear: both;display: block"></div></div> 二,增加一个容器,在代码中存在,但在视觉中不可见。Html代码如下: <divid="main"><divid="content"></div><divstyle="height:1px; margin-top:-1px;clear: both;overflow:hidden;"></div></div> 三,增加一个BR并设置样式为clear:both。Html代码如下: <divid="main"><divid="content"></div>

函数传参,改变Div任意属性的值&&图片列表:鼠标移入/移出改变图片透明度

让人想犯罪 __ 提交于 2019-12-19 09:54:01
<!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> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>函数传参,改变Div任意属性的值</title> <style> body,p{margin:0;padding:0;} body{color:#333;font:12px/1.5 Tahoma;padding-top:10px;} #outer{width:300px;margin:0 auto;} p{margin-bottom:10px;} button{margin-right:5px;} label{width:5em;display:inline-block;text-align:right;} input{padding:3px;font-family:inherit;border:1px solid #ccc;} #div1{color:#fff;width:180px

DIV Scroll属性

无人久伴 提交于 2019-12-19 04:19:06
DIV Scroll属性详解,为 DIV层 打造不同的滚动条。 一、scrollbar属性、样式详解 1.overflow内容溢出时的设置(设定被设定对象是否显示滚动条) overflow-x水平方向内容溢出时的设置 overflow-y垂直方向内容溢出时的设置 以上三个属性设置的值为visible(默认值)、scroll(出现滚动条)、hidden(隐藏)、auto()浏览器自动设置)。 2.scrollbar-3d-light-color立体滚动条亮边的颜色(设置滚动条的颜色) scrollbar-arrow-color上下按钮上三角箭头的颜色 scrollbar-base-color滚动条的基本颜色 scrollbar-dark-shadow-color立体滚动条强阴影的颜色 scrollbar-face-color立体滚动条凸出部分的颜色 scrollbar-highlight-color滚动条空白部分的颜色 scrollbar-shadow-color立体滚动条阴影的颜色 我们通过几个实例来讲解上述的样式属性: 1.设定多行文本框的滚动条 没有水平滚动条 <textarea style="overflow-x:hidden"></textarea> 没有垂直滚动条 <textarea style="overflow-y:hidden"></textarea> 没有滚动条

隐藏div的四种方式

霸气de小男生 提交于 2019-12-18 20:44:25
隐藏div是指所选择的div不显示在页面上,但是隐藏后有两种效果 1.隐藏过后的div的位置还是被占用了 2.隐藏过后的div的位置没有被占用 下面看几种隐藏div的方法 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <style type="text/css"> div { width: 300px; height: 300px; border: 1px red solid; } </style> </head> <body> <input type="button" value="显示效果" id="btn"/> <div id="box"></div>哈哈哈哈 <script src="common.js"></script> <script> document.getElementById("btn").onclick = function () { //隐藏div的三种方式 // document.getElementById("box").style.display = "none";// 不占位 // document.getElementById("box").style.visibility="hidden";//占位 // document

html+css3实现div右上角斜三角删除

戏子无情 提交于 2019-12-18 16:10:18
html 部分: <div class="box"> <div> otherthings </div> <div class="box-con"> <span>×</span> </div> </div> <div class="box"> <div> otherthings </div> <div class="box-con"> <span>×</span> </div> </div> <div class="box"> <div> otherthings </div> <div class="box-con"> <span>×</span> </div> </div> css部分: .box{ width:180px; height:100px; position:relative; background: white; overflow: hidden; border: 1px solid #cccccc; } .box .box-con{ width:60px; height:60px; position: absolute; background: red; top:-30px; right:-30px; transform: rotate(45deg); } .box .box-con span{ position: absolute; bottom:0;