草庐IT

关于 html:CSS – 调整浏览器窗口大小时修复边框宽度变化

codeneng 2023-03-28 原文

CSS - Fixed border width change when resizing browser window

我制作了 2 个简单的链接按钮,它们位于 2 个 div 标签内。

这是我试过的 csshtml 代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
.lang-box {
  position: absolute;
  bottom: 60px;
  left: 2%;
  z-index: 3;
}

.flex-container {
  display: flex;
}

.flex-direction-column {
  flex-direction: column;
}

.border-gold {
  border: 2px solid #ac8b45;
}

.text-gold {
  color: #ac8b45;
}

.background-gold {
  background-color: #ac8b45;
}

.text-black {
  color: #000;
}

.no-background {
  background-color: transparent;
}

.lang-a-button {
  text-decoration: none;
  outline: 0;
  display: block;
  font-size: 20px;
  padding-bottom: 6px;
  padding-top: 10px;
  padding-left: 6px;
  padding-right: 6px;
  height: auto;
  text-align: center;
}

.lang-a-button:hover {
  text-decoration: none;
  opacity: .7;
}
1
2
    EN
    IT

这是最终的结果:

问题是当我调整浏览器屏幕大小时,.border-gold 的右边框的粗细发生了变化:


我不明白为什么会这样。我尝试使用它,但没有任何改变。

我使用 Google Chrome v69 进行测试。

我需要添加一些东西吗?

  • 你在放大吗?
  • 不,仅调整浏览器窗口大小
  • 尝试修复链接按钮的宽度
  • 尝试添加链接flex-grow:0; flex-shrink:0;和固定宽度,像这样:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    * {
      box-sizing: border-box;
    }

    .lang-box {
        position: absolute;
        top: 60px;
        left: 2%;
        z-index: 3;
     
      width: 42px;
    }

    .flex-container{
      display: flex;
      width: 100%;
    }

    .flex-direction-column{
        flex-direction: column;
    }

    .border-gold{
        border: 2px solid #ac8b45;
    }

    .text-gold{
      color: #ac8b45;
    }

    .background-gold{
        background-color: #ac8b45;
    }

    .text-black{
        color: #000;
    }

    .no-background{
      background-color: transparent;
    }

    .lang-a-button{
        text-decoration: none;
        outline: 0;
        display: block;
        font-size: 20px;
        padding-bottom: 6px;
        padding-top: 10px;
        /* padding-left: 6px;
        padding-right: 6px; */

        height: auto;
        text-align: center;
     
      width: 100%;
      flex-grow:0;
      flex-shrink:0;
      width: 40px;
    }

    .lang-a-button:hover{
        text-decoration: none;
        opacity: .7;
    }
    1
    2
             EN
              IT

    我没有确切的答案,但我认为这是因为 flex 的特殊性

  • 尝试添加链接flex-grow:0; flex-shrink:0;和固定宽度,像这样:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    * {
      box-sizing: border-box;
    }

    .lang-box {
        position: absolute;
        top: 60px;
        left: 2%;
        z-index: 3;
     
      width: 42px;
    }

    .flex-container{
      display: flex;
      width: 100%;
    }

    .flex-direction-column{
        flex-direction: column;
    }

    .border-gold{
        border: 2px solid #ac8b45;
    }

    .text-gold{
      color: #ac8b45;
    }

    .background-gold{
        background-color: #ac8b45;
    }

    .text-black{
        color: #000;
    }

    .no-background{
      background-color: transparent;
    }

    .lang-a-button{
        text-decoration: none;
        outline: 0;
        display: block;
        font-size: 20px;
        padding-bottom: 6px;
        padding-top: 10px;
        /* padding-left: 6px;
        padding-right: 6px; */

        height: auto;
        text-align: center;
     
      width: 100%;
      flex-grow:0;
      flex-shrink:0;
      width: 40px;
    }

    .lang-a-button:hover{
        text-decoration: none;
        opacity: .7;
    }
    1
    2
             EN
              IT

    我没有确切的答案,但我认为这是因为 flex 的特殊性

  • 尝试添加链接flex-grow:0; flex-shrink:0;和固定宽度,像这样:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    * {
      box-sizing: border-box;
    }

    .lang-box {
        position: absolute;
        top: 60px;
        left: 2%;
        z-index: 3;
     
      width: 42px;
    }

    .flex-container{
      display: flex;
      width: 100%;
    }

    .flex-direction-column{
        flex-direction: column;
    }

    .border-gold{
        border: 2px solid #ac8b45;
    }

    .text-gold{
      color: #ac8b45;
    }

    .background-gold{
        background-color: #ac8b45;
    }

    .text-black{
        color: #000;
    }

    .no-background{
      background-color: transparent;
    }

    .lang-a-button{
        text-decoration: none;
        outline: 0;
        display: block;
        font-size: 20px;
        padding-bottom: 6px;
        padding-top: 10px;
        /* padding-left: 6px;
        padding-right: 6px; */

        height: auto;
        text-align: center;
     
      width: 100%;
      flex-grow:0;
      flex-shrink:0;
      width: 40px;
    }

    .lang-a-button:hover{
        text-decoration: none;
        opacity: .7;
    }
    1
    2
             EN
              IT

    我没有确切的答案,但我认为这是因为 flex 的特殊性

  • 尝试添加链接flex-grow:0; flex-shrink:0;和固定宽度,像这样:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    * {
      box-sizing: border-box;
    }

    .lang-box {
        position: absolute;
        top: 60px;
        left: 2%;
        z-index: 3;
     
      width: 42px;
    }

    .flex-container{
      display: flex;
      width: 100%;
    }

    .flex-direction-column{
        flex-direction: column;
    }

    .border-gold{
        border: 2px solid #ac8b45;
    }

    .text-gold{
      color: #ac8b45;
    }

    .background-gold{
        background-color: #ac8b45;
    }

    .text-black{
        color: #000;
    }

    .no-background{
      background-color: transparent;
    }

    .lang-a-button{
        text-decoration: none;
        outline: 0;
        display: block;
        font-size: 20px;
        padding-bottom: 6px;
        padding-top: 10px;
        /* padding-left: 6px;
        padding-right: 6px; */

        height: auto;
        text-align: center;
     
      width: 100%;
      flex-grow:0;
      flex-shrink:0;
      width: 40px;
    }

    .lang-a-button:hover{
        text-decoration: none;
        opacity: .7;
    }

    1
    2
             EN
              IT

    我没有确切的答案,但我认为这是因为 flex 的特殊性

  • 尝试添加链接flex-grow:0; flex-shrink:0;和固定宽度,像这样:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    * {
      box-sizing: border-box;
    }

    .lang-box {
        position: absolute;
        top: 60px;
        left: 2%;
        z-index: 3;
     
      width: 42px;
    }

    .flex-container{
      display: flex;
      width: 100%;
    }

    .flex-direction-column{
        flex-direction: column;
    }

    .border-gold{
        border: 2px solid #ac8b45;
    }

    .text-gold{
      color: #ac8b45;
    }

    .background-gold{
        background-color: #ac8b45;
    }

    .text-black{
        color: #000;
    }

    .no-background{
      background-color: transparent;
    }

    .lang-a-button{
        text-decoration: none;
        outline: 0;
        display: block;
        font-size: 20px;
        padding-bottom: 6px;
        padding-top: 10px;
        /* padding-left: 6px;
        padding-right: 6px; */

        height: auto;
        text-align: center;
     
      width: 100%;
      flex-grow:0;
      flex-shrink:0;
      width: 40px;
    }

    .lang-a-button:hover{
        text-decoration: none;
        opacity: .7;
    }
    1
    2
             EN
              IT

    我没有确切的答案,但我认为这是因为 flex 的特殊性

  • 尝试添加链接flex-grow:0; flex-shrink:0;和固定宽度,像这样:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    * {
      box-sizing: border-box;
    }

    .lang-box {
        position: absolute;
        top: 60px;
        left: 2%;
        z-index: 3;
     
      width: 42px;
    }

    .flex-container{
      display: flex;
      width: 100%;
    }

    .flex-direction-column{
        flex-direction: column;
    }

    .border-gold{
        border: 2px solid #ac8b45;
    }

    .text-gold{
      color: #ac8b45;
    }

    .background-gold{
        background-color: #ac8b45;
    }

    .text-black{
        color: #000;
    }

    .no-background{
      background-color: transparent;
    }

    .lang-a-button{
        text-decoration: none;
        outline: 0;
        display: block;
        font-size: 20px;
        padding-bottom: 6px;
        padding-top: 10px;
        /* padding-left: 6px;
        padding-right: 6px; */

        height: auto;
        text-align: center;
     
      width: 100%;
      flex-grow:0;
      flex-shrink:0;
      width: 40px;
    }

    .lang-a-button:hover{
        text-decoration: none;
        opacity: .7;
    }
    1
    2
             EN
              IT

    我没有确切的答案,但我认为这是因为 flex 的特殊性


尝试添加链接flex-grow:0; flex-shrink:0;和固定宽度,像这样:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
* {
  box-sizing: border-box;
}

.lang-box {
    position: absolute;
    top: 60px;
    left: 2%;
    z-index: 3;
 
  width: 42px;
}

.flex-container{
  display: flex;
  width: 100%;
}

.flex-direction-column{
    flex-direction: column;
}

.border-gold{
    border: 2px solid #ac8b45;
}

.text-gold{
  color: #ac8b45;
}

.background-gold{
    background-color: #ac8b45;
}

.text-black{
    color: #000;
}

.no-background{
  background-color: transparent;
}

.lang-a-button{
    text-decoration: none;
    outline: 0;
    display: block;
    font-size: 20px;
    padding-bottom: 6px;
    padding-top: 10px;
    /* padding-left: 6px;
    padding-right: 6px; */

    height: auto;
    text-align: center;
 
  width: 100%;
  flex-grow:0;
  flex-shrink:0;
  width: 40px;
}

.lang-a-button:hover{
    text-decoration: none;
    opacity: .7;
}
1
2
         EN
          IT

我没有确切的答案,但我认为这是因为 flex 的特殊性

有关关于 html:CSS – 调整浏览器窗口大小时修复边框宽度变化的更多相关文章

  1. ruby-on-rails - 在 Rails 中将文件大小字符串转换为等效千字节 - 2

    我的目标是转换表单输入,例如“100兆字节”或“1GB”,并将其转换为我可以存储在数据库中的文件大小(以千字节为单位)。目前,我有这个:defquota_convert@regex=/([0-9]+)(.*)s/@sizes=%w{kilobytemegabytegigabyte}m=self.quota.match(@regex)if@sizes.include?m[2]eval("self.quota=#{m[1]}.#{m[2]}")endend这有效,但前提是输入是倍数(“gigabytes”,而不是“gigabyte”)并且由于使用了eval看起来疯狂不安全。所以,功能正常,

  2. ruby - 使用 ruby​​ 将 HTML 转换为纯文本并维护结构/格式 - 2

    我想将html转换为纯文本。不过,我不想只删除标签,我想智能地保留尽可能多的格式。为插入换行符标签,检测段落并格式化它们等。输入非常简单,通常是格式良好的html(不是整个文档,只是一堆内容,通常没有anchor或图像)。我可以将几个正则表达式放在一起,让我达到80%,但我认为可能有一些现有的解决方案更智能。 最佳答案 首先,不要尝试为此使用正则表达式。很有可能你会想出一个脆弱/脆弱的解决方案,它会随着HTML的变化而崩溃,或者很难管理和维护。您可以使用Nokogiri快速解析HTML并提取文本:require'nokogiri'h

  3. ruby - capybara field.has_css?匹配器 - 2

    我在MiniTest::Spec和Capybara中使用以下规范:find_field('Email').must_have_css('[autofocus]')检查名为“电子邮件”的字段是否具有autofocus属性。doc说如下:has_css?(path,options={})ChecksifagivenCSSselectorisonthepageorcurrentnode.据我了解,字段“Email”是一个节点,因此调用must_have_css绝对有效!我做错了什么? 最佳答案 通过JonasNicklas得到了答案:No

  4. ruby-on-rails - Rails HTML 请求渲染 JSON - 2

    在我的Controller中,我通过以下方式在我的index方法中支持HTML和JSON:respond_todo|format|format.htmlformat.json{renderjson:@user}end在浏览器中拉起它时,它会自然地以HTML呈现。但是,当我对/user资源进行内容类型为application/json的curl调用时(因为它是索引方法),我仍然将HTML作为响应。如何获取JSON作为响应?我还需要说明什么? 最佳答案 您应该将.json附加到请求的url,提供的格式在routes.rb的路径中定义。这

  5. ruby-on-rails - 使用 Sublime Text 3 突出显示 HTML 背景语法中的 ERB? - 2

    所以我在关注Railscast,我注意到在html.erb文件中,ruby代码有一个微弱的背景高亮效果,以区别于其他代码HTML文档。我知道Ryan使用TextMate。我正在使用SublimeText3。我怎样才能达到同样的效果?谢谢! 最佳答案 为SublimeText安装ERB包。假设您安装了SublimeText包管理器*,只需点击cmd+shift+P即可获得命令菜单,然后键入installpackage并选择PackageControl:InstallPackage获取包管理器菜单。在该菜单中,键入ERB并在看到包时选择

  6. ruby - 在 Ruby 中用键盘诅咒数组浏览 - 2

    我正在尝试在Ruby中制作一个cli应用程序,它接受一个给定的数组,然后将其显示为一个列表,我可以使用箭头键浏览它。我觉得我已经在Ruby中看到一个库已经这样做了,但我记不起它的名字了。我正在尝试对soundcloud2000中的代码进行逆向工程做类似的事情,但他的代码与SoundcloudAPI的使用紧密耦合。我知道cursesgem,我正在考虑更抽象的东西。广告有没有人见过可以做到这一点的库或一些概念证明的Ruby代码可以做到这一点? 最佳答案 我不知道这是否是您正在寻找的,但也许您可以使用我的想法。由于我没有关于您要完成的工作

  7. ruby-on-rails - 浏览 Ruby 源代码 - 2

    我的主要目标是能够完全理解我正在使用的库/gem。我尝试在Github上从头到尾阅读源代码,但这真的很难。我认为更有趣、更温和的踏脚石就是在使用时阅读每个库/gem方法的源代码。例如,我想知道RubyonRails中的redirect_to方法是如何工作的:如何查找redirect_to方法的源代码?我知道在pry中我可以执行类似show-methodmethod的操作,但我如何才能对Rails框架中的方法执行此操作?您对我如何更好地理解Gem及其API有什么建议吗?仅仅阅读源代码似乎真的很难,尤其是对于框架。谢谢! 最佳答案 Ru

  8. ruby-on-rails - Ruby url 到 html 链接转换 - 2

    我正在使用Rails构建一个简单的聊天应用程序。当用户输入url时,我希望将其输出为html链接(即“url”)。我想知道在Ruby中是否有任何库或众所周知的方法可以做到这一点。如果没有,我有一些不错的正则表达式示例代码可以使用... 最佳答案 查看auto_linkRails提供的辅助方法。这会将所有URL和电子邮件地址变成可点击的链接(htmlanchor标记)。这是文档中的代码示例。auto_link("Gotohttp://www.rubyonrails.organdsayhellotodavid@loudthinking.

  9. ruby-on-rails - capybara ::ElementNotFound:无法找到 xpath "/html" - 2

    我正在学习http://ruby.railstutorial.org/chapters/static-pages上的RubyonRails教程并遇到以下错误StaticPagesHomepageshouldhavethecontent'SampleApp'Failure/Error:page.shouldhave_content('SampleApp')Capybara::ElementNotFound:Unabletofindxpath"/html"#(eval):2:in`text'#./spec/requests/static_pages_spec.rb:7:in`(root)'

  10. css - 用 watir 检查标签类? - 2

    我有一个div,它根据表单是否正确提交而改变。我想知道是否可以检查类的特定元素?开始元素看起来像这样。如果输入不正确,添加错误类。 最佳答案 试试这个:browser.div(:id=>"myerrortest").class_name更多信息:http://watir.github.com/watir-webdriver/doc/Watir/HTMLElement.html#class_name-instance_method另一种选择是只查看具有您期望的类的div是否存在browser.div((:id=>"myerrortes

随机推荐