小编Dad*_*dan的帖子

如何在html中将锚元素的高度填充到100%?

我已经创建了一个顶部栏,其中有height: 50px一个锚元素,锚元素,它的填充应该与顶部栏高度完全相同.

在主流浏览器中测试代码时,Firefox已经给出了顶部栏到锚元素的精确像素高度,但在ChromeIE中,它的结果为-1px. 在这里小提琴

HTML:

<div > <a href="">Text Here</a> </div>
Run Code Online (Sandbox Code Playgroud)

CSS:

div {
    width: auto;
    height: 50px;
    background-color: #333;
}
a {
    padding: 10px;
    display: inline-block;
    font-size: 24px; /* Adjusting this would affect element block size */
    color: white;
    font-family:'Bebas Neue';
    background-color: #777;
}
a:hover { background-color: green; }
Run Code Online (Sandbox Code Playgroud)

我怎样才能填充<a>锚元素的尺寸达到div的高度?

html css

6
推荐指数
1
解决办法
6106
查看次数

自定义控件的文本框字符串/文本的填充

我是新手,最近才问这个问题问题,它告诉我如何为 TextBox 的底部边框提供最佳选择,以防止由绘制的图形导致的闪烁/撕裂。

现在我的问题是如何为文本框中的文本/字符串设置边距/填充,代码如下:

using System.Drawing;
using System.Windows.Forms;

namespace main.Classes.CustomControls {

    class TextBoxMaterial : TextBox {
        public TextBoxMaterial() {
            this.BorderStyle = System.Windows.Forms.BorderStyle.None;
            this.Controls.Add(new Label() {
                Height = 2,
                Dock = DockStyle.Bottom,
                BackColor = Color.Gray,
            });
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

当前文本框:

在此输入图像描述

我需要拥有什么:

在此输入图像描述

c# user-interface margins padding winforms

5
推荐指数
1
解决办法
5169
查看次数

计算多维数组的第一维

现在我可以使用var_num=sizeof(var)/sizeof(var[0]);我研究过并在我的代码中使用的方式来计算第一个维度,但问题是我不知道它是如何工作的,在我的输出中它显示了20 / 4 = 5并且我无法弄清楚它在哪里20 和 4 来自,我只想问这些值是如何通过sizeof(var)和获取的sizeof(var[0]),那个零是什么意思,它是指第一维还是第二维?

#include <stdio.h>
#include <conio.h>
void main(){
char *var[][2]={
        {"var0-0","var0-1"},
        {"var1-0","var1-1"},
        {"var2-0","var2-1"},
        {"var3-0","var3-1"},
        {"var4-0","var4-1"},
        };
int var_num=sizeof(var)/sizeof(var[0]);
clrscr();
printf("%d / %d = %d",sizeof(var),sizeof(var[0]),var_num);
getch();
}
Run Code Online (Sandbox Code Playgroud)

c arrays pointers sizeof

3
推荐指数
1
解决办法
395
查看次数

使用指针的数组内存地址分配声明的相同优先级

我已经研究过并且我清楚地知道数组不是指针
但是我已经学到了一些我认为可能使用指针声明声明类似数组的变量的东西.我知道的事情:

  • 声明指针使用解除引用运算符:int *x;
  • 在声明指针时,我知道它只保存内存地址......
  • 使用指针回显数组中的值将是:
  • 声明时a[3],它在堆栈上分配3个空的内存地址.
    因此,它是好像是说*(a+0),*(a+1),*(a+3)是在堆栈的使用分配. 数组<code>a</code>3的范围</noimg></li>
</ul>

<p><strong>我想使用指针执行相同的内存地址分配声明优先级</strong></p>

<p>我可以使用指针做那样的事吗?<br>将指针声明指向指向获取不同地址的指针很容易<code>**p</code><br></p>

<p>我期待有可能创建一个指针声明,从当前地址和它遵循的地址分配内存,所以它将是类似数组的结构</p>

<p>示例:我知道<code>int a[3];</code>使用指针声明不会只是<code>int *(a+3)</code>
<br><em>如果我问的是不可能请回答原因.</em></p>

<hr>

<p>这是普通数组声明和调用的简单代码:<a rel=Ideone Code

    #include <stdio.h>
    char block[3]={1,2,3};// This line will be removed
    //And would create a pointer declaration of that having array-like structure
    
    int main() {
        while(i < sizeof(block))
        printf("%d", block[i++]);
        //And that I still …
    Run Code Online (Sandbox Code Playgroud)

c arrays pointers memory-management

2
推荐指数
2
解决办法
322
查看次数

具有底部边框的文本框

我想TextBox使用底部边框,但TextBox由于,为绘制的图形在调整大小时变形/损坏Color.Transparent

使用找到的代码,我可以创建一个带下划线的TextBox(带有透明的顶部,左侧,右侧的绘制矩形)。问题是当我调整窗体/窗口的大小时:当我将其大小缩小到较小的大小,然后再次调整大小以展开它时,绘制的图形会失真。有什么解决办法吗?

这些是照片:第二张照片已经被调整为较小的尺寸,然后再放大为较大的尺寸。 正常收缩然后扩大

这是代码:

[DllImport("user32")]
    private static extern IntPtr GetWindowDC(IntPtr hwnd);
    struct RECT {
        public int left, top, right, bottom;
    }
    struct NCCALSIZE_PARAMS {
        public RECT newWindow;
        public RECT oldWindow;
        public RECT clientWindow;
        IntPtr windowPos;
    }

    float clientPadding = 0;
    int actualBorderWidth = 2;
    Color borderColor = Color.Black;
    protected override void WndProc(ref Message m) {
        //We have to change the clientsize to make room for borders
        //if not, the border is limited …
Run Code Online (Sandbox Code Playgroud)

c# graphics user-interface winforms window-resize

2
推荐指数
1
解决办法
5576
查看次数

为什么" - - "和"+ ++"以不同的方式运作?

减少/增量是一项基本操作,但它优先于我- --并使+ ++我感到困惑.我将使用减量来说明:

我在这里有一套不同风格的操作ab:在这里工作

#include <iostream>
using namespace std;
int a=10, b=7;
int main() {
// - and -- opearator                         // Results:  Details:
    a = 10, b = 7; cout << a---b << endl;     //    3      a post-decrement        
    a = 10, b = 7; cout << a ---b << endl;    //    3      a post-decrement     
    a = 10, b = 7; cout << a- --b << endl;    //    4      b pre-decrement    
    a …
Run Code Online (Sandbox Code Playgroud)

c++ increment operator-precedence decrement

1
推荐指数
1
解决办法
225
查看次数

C:输出打印未回显的变量内的值

我有这个非常简单的C代码,它必须回显x数组中的值,令人惊讶的是,它还回应了数组中的值y...

#include <iostream.h>
#include <conio.h>
#include <string.h>

int     i;
char    x[3]={'a','b','c'},
        y[3][2]={
             {'a','A'},
             {'b','B'},
             {'c','C'}};
void main(){
    clrscr();
    while(i<strlen(x)) cout << x[i++] << endl;
    getch();
}
Run Code Online (Sandbox Code Playgroud)

输出:

a
b
c
a
A
b
B
c
C
Run Code Online (Sandbox Code Playgroud)

显然,前3个字符是我真正打算回应的
那些... 但是那些跟随数组的字符怎么样y

c echo

0
推荐指数
1
解决办法
61
查看次数