div

CSS基础——img元素与同级div元素存在间隙

坚强是说给别人听的谎言 提交于 2020-01-21 23:48:50
背景: 在练习flex布局时无意间发现img元素与同级div元素之间存在间隙,网上虽然有解决方法,但是却不知道为什么这么做,在这里记录下我的观点。 原因 代码示例: < header > < img class = " profile-thumbnail " src = " https://freecodecamp.s3.amazonaws.com/quincy-twitter-photo.jpg " alt = " Quincy Larson ' s profile picture " > < div class = " profile-name " > < h3 > Quincy Larson </ h3 > < h4 > @ossia </ h4 > </ div > < div class = " follow-btn " > < button > Follow </ button > </ div > </ header > body { font-family : Arial, sans-serif ; } header { /*display: flex;*/ background : bisque ; } header .profile-thumbnail { width : 50px ; height : 50px ; border-radius : 4px ;

Codeforces Round #569 (Div. 2) B. Nick and Array

孤街醉人 提交于 2020-01-21 17:26:21
原文链接: https://codeforces.com/contest/1180/problem/B 题意:给你n个数,你要进行一次或者多次操作(操作的方式a[i]=-a[i]-1),让它们的乘积最大,当然也可以不进行操作,答案有多组。 思路:根据(操作的方式a[i]=-a[i]-1),我们发现,正数进行操作后,绝对值变大了,那么想让全部数乘积最大,就让这组数全变成负数(是不是好奇,如果存在0的问题,0进行操作可以变为(-1)),然后判断个数n的奇偶,偶数就直接输出,奇数的话把最小(除去-1)的变为正数就行了. 代码: 1 #include"iostream" 2 #include"algorithm" 3 #include"cstring" 4 #include"cstdio" 5 #include"cmath" 6 using namespace std; 7 #define ll long long 8 int main(){ 9 std::ios::sync_with_stdio(false); 10 ll n; 11 while(cin>>n){ 12 ll a[n],b[n]; 13 for(int i=0;i<n;i++) { 14 cin>>a[i]; 15 if(a[i]==0) a[i]=-1; 16 if(a[i]>0) a[i]=a[i]*(-1)-1;

div上添加遮罩层用于提示信息

流过昼夜 提交于 2020-01-21 05:29:03
下面为完整代码,直接复制的页面即可使用 <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=8" /> <style type="text/css"> .black_overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: black; z-index: 1001; -moz-opacity: 0.8; opacity: .80; filter: alpha(opacity=80); } .white_content { display: none; position: fixed; top: 20%; left: 10%; width: 80%; height: 50%; border: 1px solid black; background-color: white; z-index: 1002; overflow: auto; } .shut_down{ text-align: right; cursor: default;

vue实现拖动div元素

孤人 提交于 2020-01-21 02:49:59
html: <div id="app1"> <div v-drag class="drag"></div> <div v-drag class="drag"></div> </div> css: .drag{ width: 100px; height: 100px; position: absolute; top: 0; left: 0; background-color: red; } js: // 拖动div元素 let vm1 = new Vue({ el:'#app1', // 自定义指令 directives:{ drag(el,bindings){ el.onmousedown = function(e){ var disx = e.pageX - el.offsetLeft; var disy = e.pageY - el.offsetTop; document.onmousemove = function (e){ el.style.left = e.pageX - disx+'px'; el.style.top = e.pageY - disx+'px'; } document.onmouseup = function(){ document.onmousemove = document.onmouseup = null; } } } } }) 来源: https

Codeforces Round #614 (Div. 2) C. NEKO's Maze Game

懵懂的女人 提交于 2020-01-20 00:48:59
题目链接: http://codeforces.com/contest/1293/problem/C 题意:给定n,q,即给定一个2*n的格子,有q个查询。 每个查询给定一个r i 和c i ,r i 为1或2,c i 在1到n之间,即给定一个(r i ,c i ),该点自该查询起状态进行转变(可经过/不可经过)。 如某个查询给定1,2,即点(1,2)无法经过,若之后查询再次给定1,2,则该点(1,2)可以经过。 问能否从(1,1)走到(2,n),保证给定的查询不会经过起点和终点。 思路: 由于n和q最大都是1e5,所以不能直接n*q暴力。 由于有三千个人做出来,所以是水题:) 不要想太多:) 线段树应该可以做 枚举每个无法经过的点应该也可以做,但是貌似要删点 因为一个点只会对附近最多三个点产生影响 所以可以直接O(q),加点时加上对应的贡献,在删点时把它删掉即可。 #include<bits/stdc++.h> using namespace std; const int maxn=1e5+10; int c[2][maxn]; int main() { int n,q; scanf("%d%d",&n,&q); for(int i=0;i<q;i++) { int x,y; scanf("%d%d",&x,&y); x--; if(c[x][y]) { c[x][y]=0;

Codeforces Round #613 (Div. 2)B. Just Eat It!

断了今生、忘了曾经 提交于 2020-01-19 20:05:52
B. Just Eat It! time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Today, Yasser and Adel are at the shop buying cupcakes. There are nn cupcake types, arranged from 11 to nn on the shelf, and there are infinitely many of each type. The tastiness of a cupcake of type ii is an integer aiai. There are both tasty and nasty cupcakes, so the tastiness can be positive, zero or negative. Yasser, of course, wants to try them all, so he will buy exactly one cupcake of each type. On the other hand, Adel will choose some segment [l,r][l,r] (1≤l≤r≤n

如何强制子div为父div的高度的100%而不指定父级的高度?

人走茶凉 提交于 2020-01-19 00:10:28
我有一个具有以下结构的网站: <div id="header"></div> <div id="main"> <div id="navigation"></div> <div id="content"></div> </div> <div id="footer"></div> 导航位于左侧,内容div位于右侧。 内容div的信息通过PHP引入,因此每次都不同。 我如何垂直缩放导航,使其高度与内容div的高度相同,无论加载哪个页面? #1楼 注意 :此答案适用于不支持Flexbox标准的旧版浏览器。 有关现代方法,请参阅: https : //stackoverflow.com/a/23300532/1155721 我建议你看一下 使用跨浏览器CSS和无黑客的Equal Height Columns 。 基本上,使用CSS以浏览器兼容的方式执行此操作并非易事(但对于表格而言是微不足道的),因此请找到适合您的预打包解决方案。 此外,答案取决于您是想要100%高度还是相同高度。 通常它的高度相等。 如果它是100%高度,答案会略有不同。 #2楼 [在另一个答案中提到Dmity的Less代码]我猜这是某种“伪代码”? 从我的理解尝试使用应该做的技巧的人造柱技术。 http://www.alistapart.com/articles/fauxcolumns/ 希望这可以帮助 :) #3楼

Codeforces Round #604 (Div. 2)(A-E)

纵饮孤独 提交于 2020-01-18 12:25:41
A. Beautiful String 题意:把'?'换成'a' or 'b' or 'c'使得相邻的两个字符不相同。 暴力枚举每个'?'前后。 #include <bits/stdc++.h> using namespace std; const int MAXN=1e5+10; string s; int main(){ ios::sync_with_stdio(false); int T; cin>>T; while(T--){ cin>>s; bool ok=true; for(int i=0;i<s.size();i++){ if(i!=0&&s[i]==s[i-1]){ ok=false; break; } if(s[i]=='?'){ bool a=false,b=false,c=false; if(i!=0){ if(s[i-1]=='a')a=true; else if(s[i-1]=='b')b=true; else if(s[i-1]=='c')c=true; } if(s[i+1]=='a')a=true; else if(s[i+1]=='b')b=true; else if(s[i+1]=='c')c=true; if(!a)s[i]='a'; else if(!b)s[i]='b'; else if(!c)s[i]='c'; } } if(!ok

JS实现div拖拽

耗尽温柔 提交于 2020-01-18 05:18:23
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>拖拽</title> <style type="text/css"> #div{ position: absolute; width: 150px; height: 150px; background: cadetblue; } </style> </head> <body> <div id="div"></div> <script> //div按下事件 var Div = document.getElementById("div"); Div.onmousedown = function (e) { // console.log("down"); disX=e.clientX - Div.offsetLeft;//获取鼠标到div left的距离 disY=e.clientY - Div.offsetTop;//获取鼠标到div top的距离 //console.log(disX+' '+disY); document.onmousemove = function (e) {//处理鼠标滑动过快,脱离div,所以在document上添加事件 //console.log("move"); Div.style.left = e.clientX

Codeforces Round #613 (Div. 2)A-C

天涯浪子 提交于 2020-01-16 05:20:51
文章目录 A - Mezo Playing Zoma 题目 题意 思路 代码 B - Just Eat It! 题目 题意 思路 代码 C - Fadi and LCM 题意 思路 代码 A - Mezo Playing Zoma 题目 Today, Mezo is playing a game. Zoma, a character in that game, is initially at position x=0. Mezo starts sending n commands to Zoma. There are two possible commands: ‘L’ (Left) sets the position x:=x−1; ‘R’ (Right) sets the position x:=x+1. Unfortunately, Mezo’s controller malfunctions sometimes. Some commands are sent successfully and some are ignored. If the command is ignored then the position x doesn’t change and Mezo simply proceeds to the next command. For example, if