position

35. Search Insert Position

醉酒当歌 提交于 2020-01-24 17:54:41
Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You may assume no duplicates in the array. Example 1: Input: [1,3,5,6], 5 Output: 2 Example 2: Input: [1,3,5,6], 2 Output: 1 Example 3: Input: [1,3,5,6], 7 Output: 4 Example 4: Input: [1,3,5,6], 0 Output: 0 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/search-insert-position 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 class Solution { public int searchInsert ( int [ ] nums , int target ) { if ( target > 4 ) { for ( int i = nums . length - 1 ; i

46-jQuery弹窗广告

拈花ヽ惹草 提交于 2020-01-24 14:02:35
< ! DOCTYPE html > < html lang = "en" > < head > < meta charset = "UTF-8" > < title > 46 - jQuery弹窗广告 < / title > < style > * { margin : 0 ; padding : 0 ; } div { position : fixed ; right : 0 px ; bottom : 0 px ; display : none ; } . ad { /*position: relative;*/ } . ad > span { display : inline - block ; width : 30 px ; height : 30 px ; background : red ; position : absolute ; right : 0 ; top : 0 ; } < / style > < script src = "js/jquery-1.9.1.min.js" > < / script > < script > $ ( function ( ) { //1.监听span的点击事件 $ ( "span" ) . click ( function ( ) { $ ( ".ad" ) . remove ( ) ; } ) //2.执行广告动画 //

CSS, image with height:auto, covers div beneath it upon screen resize (phone held horizontally)

旧城冷巷雨未停 提交于 2020-01-24 12:45:46
问题 I'm designing the mobile phone portion of my website. I have a, top:0%, position:fixed, banner image with, width:100%, and height:auto. As the phone is turned horizontally the banner image scales nicely covering the screen width. However my issue is in positioning content below this image. For example a div with position:absolute, and top:20%, displays a div below the banner for a vertical screen. Unfortunately when turning the screen horizontally, the image enlarges, and covers the div. Is

Java版八荣八耻

旧时模样 提交于 2020-01-24 08:39:07
以动手实践为荣,以只看不练为耻 以打印日志为荣,以出错不报为耻 以局部变量为荣,以全局变量为耻 以单元测试为荣,以手工测试为耻 以代码重用为荣,以复制粘贴为耻 以多态应用为荣,以分支判断为耻 以定义常量为荣,以魔法数字为耻 以总结思考为荣,以不求甚解为耻 多态应用: 动物–叫 鸟-叫—歌唱 狮子-叫–咆哮 猫-叫–喵喵喵 反思,项目里的抽象和继承往往需要花比较多的时间来思考,在真实业务场景中,要先完成实现,再做代码结构的优化,往往在完成了一大堆的ifelse之后,再来做这种层面的优化,工作量基本相当于再写一遍,做的人也比较少。 实例分析: Position ClosePosition ForwardPosition OpenPosition 这三个对象,从理论上来说是可以通过多态来做的,但在真实项目中就是采用了一个position,并使用不同的变量名来做区分, ifelse使用得非常之多。 现在来分析,重构该怎么做,会优化多少? 首先position提供公共的方法,由三个子类去实现,在service层只要将对象转为对应的子类就能完成。 很显然,代码会变成这样 Position p; if (A) p=new ClosePosition(); else if (B) p=new ForwardPosition(); p.add(trade); 优点:公共的代码可以放在父类的方法里

纯CSS气泡框实现方法探究

大兔子大兔子 提交于 2020-01-24 05:16:54
气泡框(或者提示框)是网页中一种很常见的元素,大多用来展示提示信息,如下图所示: 拆分来看,形如这种气泡框无外乎就是一个矩形框+一个指示方向的三角形小箭头,要制作出这样的气泡框,如果解决了三角形小箭头就容易了。一种方法就是制作这样一个三角形箭头的图片,然后定位在矩形框上。但这种解决办法在后期更改气泡框会很不方便,可能每修改一次气泡框都要重新制作一个三角形小图标。如果我们能够直接用HTML和CSS代码实现这样一个三角形小箭头一切都迎刃而解了。 首先我们来看一下border这个属性,当我们把一个div的border-color设为不同值的时候,可以看到四边都成了一个梯形。 1 # test{ width : 50px ; height : 50px ; border-width : 50px ; border-style : solid ; border-color : #09F #990 #933 #0C9 ;} 如果我们继续把这个div的width和height都设为0,可以看到四边都成了一个三角形。 1 # test{ width : 0 ; height : 0 ; border-width : 75px ; border-style : solid ; border-color : #09F #990 #933 #0C9 ;} 在主流浏览器中检测一下

用css3实现各种图标效果

十年热恋 提交于 2020-01-24 05:04:31
原文: 用css3实现各种图标效果 公共样式 应该说现在绝大多数公司的项目前端都是一团乱,不仅仅是js写的没有任何框架而言,css同样也是如此,导致项目如果要升级或者说有新的变更维护起来就特别困难。 最近领导决定花大时间整理一下css样式,用他的一句话来说就是为后来者造福。 首先我们在整理样式之前,必须得有一个自己团队的规范。 思考真的很重要,所谓的磨刀不误砍柴工,事实上也就是说你在做任何事情之前都要把大致的流程,大致的思路想清楚之后再动手,否则就可能做到一半发现这样不对,然后前面的工夫全白费了,这样启不是。。。 前面说了一堆费话,下面就简单点来介绍一下我整理的图标(全部用css来实现的)。 css没有继承、多态等,所以为了write less ,do more就不得不想尽各种方法(我们自己规定凡是公共的、组件级别的样式全部以u-开头)。 我这里因为写所有标签的样式名都是以u-icon开头,所以写了如下样式,这样的话所有的以u-icon开头的全部都应用了如下三个样式,你想如果你有100个u-icon的样式那就省去了你300行代码呀! [class^="u-icon"] { display: inline-block; color: #fff; vertical-align: middle; } 手机上的切换标签 css样式代码: /*手机上的切换标签*/ .u-icon

用css3实现各种图标效果(2)

不想你离开。 提交于 2020-01-24 05:03:55
原文: 用css3实现各种图标效果(2) 写在前面 写的一模一样的css样式,结果却导致原来出来不一样的效果图。 用chrome的开发者工具查看,比较起来还是一模一样的css样式,可为什么会出现不一样的placeholder效果呢?一个白色粗体,一个灰色正常字体。 找了老半天找不到原因 后来才发现是我同事写的框架css里面代码的一句话影响到了 ::-webkit-input-placeholder { color: #a4afc6; } 可是为什么在chrome控制台看不到这句代码呢?请教了一番同事,原来是这样的。 1、点击控制台“设置”按钮 2、按如下所示设置,选中“Show user agent shadow DOM” 3、你就会在elements控制面板里面能看到如下所示 回归正题,继续我的css各种图标。。。。 当然在开始之前,还是加上如下这段公共样式吧! [class^="u-icon"] { display: inline-block; color: #fff; vertical-align: middle; } 各种删除按钮(不用图标只能css来实现) html代码如下: <span class="u-icon-radioDelete"></span> <span class="u-icon-deleteToggle Orange"> <span class="u

MongoDB 数组

Deadly 提交于 2020-01-24 04:57:06
MongoDB是文档型数据库,每个文档(doc)表示数据的一项记录。相比关系型DB的row只能使用简单的数据类型,doc能够使用复杂的数据类型:内嵌doc,数组。MongoDB的数组是一系列元素的集合,使用中括号 [] 表示数组,例如:[1,2,3]的元素是整数值,[{name:"t5"}, {name:"t7"}],[ {name:"t5", age:21}, {name:"t7", age:22} ]的元素是doc。 在MongoDB中,数组元素允许重复,元素的位置是固定的。如果两个数组相等,那么这两个数组的元素和及其位置都相同。 创建示例collection,使用db.collection.insert()函数和数组参数,一次性向集合中插入3个doc。 user1={ name:"t1", age:21} user2={ name:"t2", age:22} user3={ name:"t3", age:23} db.users.insert([user1,user2,user3]) 一,使用dot标记法(dot notation)访问数组元素 MongoDB使用 dot 访问数组的元素,或内嵌doc字段。 MongoDB uses the dot notation to access the elements of an array and to access the

css position: absolute、relative详解

99封情书 提交于 2020-01-24 02:38:47
CSS2.0 HandBook上的解释: 设置此属性值为 absolute 会将对象拖离出正常的文档流绝对定位而不考虑它周围内容的布局。假如其他具有不同 z-index 属性的对象已经占据了给定的位置,他们之间不会相互影响,而会在同一位置层叠。此时对象不具有外补丁( margin ),但仍有内补丁( padding )和边框( border )。 要激活对象的绝对(absolute)定位,必须指定 left , right , top , bottom 属性中的至少一个,并且设置此属性值为 absolute 。否则上述属性会使用他们的默认值 auto ,这将导致对象遵从正常的HTML布局规则,在前一个对象之后立即被呈递。 TRBL属性(TOP、RIGHT、BOTTOM、LEFT)只有当设定了position属性才有效。 当设定position:absolute 如果父级(无限)没有设定position属性,那么当前的absolute则结合TRBL属性以浏览器左上角为原始点进行定位 如果父级(无限)设定position属性,那么当前的absolute则结合TRBL属性以父级(最近)的左上角为原始点进行定位。 当设定position: relative 则 参照父级(最近)的内容区的左上角为原始点结合TRBL属性进行定位(或者说相对于被定位元素在父级内容区中的上一个元素进行偏移)

How to make an element slide with the viewport as it scrolls?

天涯浪子 提交于 2020-01-23 20:44:08
问题 I've Googled for this but must be using the wrong keywords. Basically I want to use the effect that Magento and now Stack Overflow uses. That is, there is an element in a column, and when you scroll down, it sticks to the top of the viewport. And once scrolled up again, it goes back into the normal page flow. This Ask A Question is a good page for example. Scroll down and watch the "How to Format" element come down (might need to make your viewport smaller if you have a large screen to see