padding

浮动广告代码

假装没事ソ 提交于 2019-12-25 01:32:07
浮动广告代码 <div id="img" style="position:absolute;; width: 200; height: 151">广告内容</div> <script LANGUAGE="JavaScript"> var xPos = 20; var yPos = 10; img.style.left= xPos; img.style.top = yPos; var step = 1; var delay = 30; var width,height,Hoffset,Woffset; var y = 1; var x = 1; var interval; img.visibility = "visible"; function changePos() { width = document.body.clientWidth; height = document.body.clientHeight; Hoffset = img.offsetHeight; Woffset = img.offsetWidth; if (y) { yPos = yPos + step; } else { yPos = yPos - step; } if (yPos < 0) { y = 1; yPos = 0; } if (yPos >= (height - Hoffset)) { y =

前端练手小项目——贪吃蛇

被刻印的时光 ゝ 提交于 2019-12-25 01:23:10
前端练手小项目——贪吃蛇 虽然不难 但是可以说 从头到尾都是自己想的!开心 下面说一下js方面的详细思路以及遇到的问题,独立写下来还是收获比较大 这里我的规则就是简化的版本,也就是随机出现食物,每次蛇吃到长度就加一。 〇、html css布局中需要注意的几个小点 game游戏框宽高必须设置为蛇小块宽高的整数倍,这样才能准确判断蛇是否会碰到边框; 其实这个游戏布局比较简单,主要在宽高的设置时要注意border之类的会影响盒子的实际宽高的情况,用 box-sizing=border-box; 也可以,自己算也可以; 这里列一下盒子基本模型以及对应的jQuery方法 width() - 设置或返回元素的宽度 height() - 设置或返回元素的高度 innerWidth() - 返回元素的宽度(包含 padding) innerHeight() - 返回元素的高度(包含 padding) outerWidth() - 返回元素的宽度(包含 padding + border) outerWidth(true) - 返回元素的宽度(包含 padding + border + margin) 这里蛇小块的定位都采用相对定位,在设置位置变化的时候直接用css的left top修改,一开始我用的offset().left来判断,但用这个修改有一个极大的问题,也就是它未定为就还在文档流中

CSS & Regex, switching values of padding or margin property

僤鯓⒐⒋嵵緔 提交于 2019-12-25 00:37:27
问题 I have CSS code where I want to find Padding -or- Margin Properties (where it has 4 values) and to switch the left value with right value: e.g. padding: 1px 2px 3px 4px; - to be like this - padding: 1px 4px 3px 2px; How can I achieve this with regex & PHP? :-) 回答1: Try this: preg_replace( '/padding:\s*?(\d*px)\s*(\d*px)\s*(\d*px)\s*(\d*px)\s*?;/i', 'padding: $1 $4 $3 $2;', $css ); Explanation \s matches a space \d matches a digit \d*px will match any digits followed by a 'px' 来源: https:/

c# Encryption in a multi-layered Streams read/write

自古美人都是妖i 提交于 2019-12-24 18:28:40
问题 There are files created from multiple layers of data: //input is not always the same, but the structure is, so for example there might be h4 and h5, but I will know that, so that is not the problem private void generalizationofwrittendata(string filename, int someint, int chunks, string outputfilename, ICryptoTransform crypt, byte[] somedata, int h1, int h2, int h3) { using (FileStream fs = new FileStream(outputfilename, FileMode.Create, FileAccess.Write)) { using (BinaryWriter w = new

Why does my structure element carry padding bytes?

纵饮孤独 提交于 2019-12-24 13:06:56
问题 I have a confusing behaviour with the memory alignment of structure elements. Consider these two structures: typedef struct s_inner { unsigned long ul1; double dbl1; fourth_struct s4; unsigned long ul2; int i1; } t_inner; typedef struct s_outer { other_struct member1; /* 4-byte aligned, 40 bytes in terms of sizeof() */ unsigned long member2; t_inner member3; /* see above */ } t_outer; When I inspect the memory layout of t_outer, I could see that the elements of member1 are 4-byte aligned,

What's the best candidate padding char for url-safe and filename-safe base64?

丶灬走出姿态 提交于 2019-12-24 11:03:05
问题 The padding char for the official base64 is '=', which might need to be percent-encoded when used in a URL. I'm trying to find the best padding char so that my encoded string can be both url safe (I'll be using the encoded string as parameter value, such as id=encodedString) AND filename safe (I'll be using the encoded string directly as filename). Dot ('.') is a popular candidate, it's url safe but it's not exactly filename safe: Windows won't allow a file name which ends with a trailing dot

Strange 5px Margin

倾然丶 夕夏残阳落幕 提交于 2019-12-24 10:47:42
问题 I am building a website here: argit.bounde.co.uk I have been searching for hours to try and find the solutions. I am trying to build my own slider which will be fluid width so I cant define height / width where possible. I have got the bulk of the slider working with stock images however when I put elements underneath it they are 5px lower than they are meant to be. This happens in all browsers except IE that I have tested. I want to give the banner which is underneath my slider a negative

OpenSSL EVP_CIPHER_CTX_set_padding not working

℡╲_俬逩灬. 提交于 2019-12-24 08:00:00
问题 I am trying to encrypt/decrypt using AES, CBC and PKCS#7 padding using the EVP interface. I am using the example found on the Wiki. I am doing EVP_CIPHER_CTX_set_padding(ctx, 0) after creating and initializing the context which should not add padding and fail if the plaintext is not a multiple of 16 bytes. Despite this the ciphertext always contains an extra block made up of padding only. The code I am using is literally copied and pasted from the tutorial, I am only adding EVP_CIPHER_CTX_set

Struct padding for single member structs

懵懂的女人 提交于 2019-12-24 03:53:27
问题 I was looking to make a struct which was an arbitrary size, known at compile time. (for use in a macro). eg: /* assume sizeof(SomeStruct) could be an odd number, * if it is using GCC's 'packed' attribute for eg */ struct { unsigned char data[sizeof(SomeStruct)]; } a, *tmp; tmp = (void *)some_data a = *tmp; However I was concerned that struct padding may increase the size of the struct so it is larger than the member, I was assured that the size of a single member struct will always be the

Simple way to calculate padding based on modulo/remainder

女生的网名这么多〃 提交于 2019-12-23 19:42:07
问题 If I have a string of length L=77 that I want to pad to a length that is a multiple of N=10. I am interested in computing just the amount of padding required. This can be easily done with N - (L % N) , except for cases where L % N is zero. I have been using the following for now: pad = (N - (L % N)) % N This does not seem particularly legible, so sometimes I use pad = N - (L % N) if pad == N: pad = 0 It seems overkill to use three lines of code for something so simple. Alternatively, I can