width 相关问题

确定X轴上对象大小的属性。此测量的最常见形式是像素或毫米。

CSS div 宽度不起作用

我有一个奇怪的问题。我的一个 div 的宽度不起作用。我的CSS就像 .产品信息 { 顶部边距:10px; 背景:#444; 宽度:850px; } .产品图片 { 宽度:350px; 文字-

回答 6 投票 0

如何设置 Bootstrap 4 toast 的宽度?

我有一个带有 Bootstrap 4 toast 的页面,我将 toast 的位置设置为位置:固定。整个吐司部分如下所示: 我有一个带有 Bootstrap 4 toast 的页面,我将 toast 的位置设置为 postion: fixed。整个吐司部分是这样的: <div class="container mt-5"> <button type="button" class="btn btn-primary" id="liveToastBtn">Toast it</button> <div id="toastContainer" style="position: fixed; top: 1.5vw; right: 1vw; bottom: 4.5vw; z-index: 9;"> <div class="toast show" role="alert" aria-live="assertive" aria-atomic="true"> <div class="toast-header"> <img src="..." class="rounded mr-2" alt="..."> <strong class="mr-auto">Bootstrap</strong> <small>11 mins ago</small> <button type="button" class="ml-2 mb-1 close" data-dismiss="toast" aria-label="Close"> <span aria-hidden="true">&times;</span> </button> </div> <div class="toast-body"> Hello, world! This is a toast message. </div> </div> </div> </div> 您可以在 this JSFiddle 中找到完整的工作代码。 该作品按原样工作得很好,但现在我想将 toast 的宽度设置为视口的 50% 左右。在 <div id="toastContainer"...> 行中,我尝试设置 width 属性: <div id="toastContainer" style="position: fixed; top: 1.5vw; width: 50%; right: 1vw; bottom: 4.5vw; z-index: 9;"> 或者我尝试设置left: <div id="toastContainer" style="position: fixed; top: 1.5vw; left: 50%; right: 1vw; bottom: 4.5vw; z-index: 9;"> 但在这两种情况下,出现的 toast 的 width 都不会改变(仅其水平 position)。 如何设置 Bootstrap 4 toast 的宽度? 我找到了办法。它也有帮助,它在网站上,我可以直接在上面尝试东西,让事情变得更容易。 我不知道你是否熟悉 bootstrap 但是有这样的东西可以让你通过将 class="col-x" (x 在 1-12 之间)的东西放入 a 中来“控制”东西的长度div 与 class="row"。 <div class="row"> <button type="button" class="btn btn-primary col-8" id="liveToastBtn">Toast it</button> </div> 正如你所看到的,这就是我所做的,只需在按钮的类中添加 col-8 即可,你可以更改它,但我发现 6 看起来不像 50% 8 更接近。 然后你需要一些CSS来使按钮居中: .row{ display:flex; justify-content:center; } 希望这就是您正在寻找的🥶🥶🥶🥶🥶🥶

回答 1 投票 0

宽度:继承/100% 子级

我想在图像顶部放置一个侧边栏,其宽度与图像相同。宽度都不是:继承|100% 工作。 CSS 身体 { 显示:柔性; } #主图片{ ...

回答 1 投票 0

如何设置 Bootstrap 4 toast 的宽度?

我有一个带有 Bootstrap 4 toast 的页面,我将 toast 的位置设置为位置:固定。整个吐司部分如下所示: 我有一个带有 Bootstrap 4 toast 的页面,我将 toast 的位置设置为 postion: fixed。整个吐司部分是这样的: <div class="container mt-5"> <button type="button" class="btn btn-primary" id="liveToastBtn">Toast it</button> <div id="toastContainer" style="position: fixed; top: 1.5vw; right: 1vw; bottom: 4.5vw; z-index: 9;"> <div class="toast show" role="alert" aria-live="assertive" aria-atomic="true"> <div class="toast-header"> <img src="..." class="rounded mr-2" alt="..."> <strong class="mr-auto">Bootstrap</strong> <small>11 mins ago</small> <button type="button" class="ml-2 mb-1 close" data-dismiss="toast" aria-label="Close"> <span aria-hidden="true">&times;</span> </button> </div> <div class="toast-body"> Hello, world! This is a toast message. </div> </div> </div> </div> 您可以在 this JSFiddle 中找到完整的工作代码。 该作品按原样工作得很好,但现在我想将 toast 的宽度设置为视口的 50% 左右。在 <div id="toastContainer"...> 行中,我尝试设置 width 属性: <div id="toastContainer" style="position: fixed; top: 1.5vw; width: 50%; right: 1vw; bottom: 4.5vw; z-index: 9;"> 或者我尝试设置left: <div id="toastContainer" style="position: fixed; top: 1.5vw; left: 50%; right: 1vw; bottom: 4.5vw; z-index: 9;"> 但在这两种情况下,出现的 toast 的 width 都不会改变(仅其水平 position)。 如何设置 Bootstrap 4 toast 的宽度? 我找到了办法。它也有帮助,它在网站上,我可以直接在上面尝试东西,让事情变得更容易。 我不知道你是否熟悉 bootstrap 但是有这样的东西可以让你通过将 class="col-x" (x 在 1-12 之间)的东西放入 a 中来“控制”东西的长度div 与 class="row"。 <div class="row"> <button type="button" class="btn btn-primary col-8" id="liveToastBtn">Toast it</button> </div> 正如你所看到的,这就是我所做的,只需在按钮的类中添加 col-8 即可,你可以更改它,但我发现 6 看起来不像 50% 8 更接近。 然后你需要一些CSS来使按钮居中: .row{ display:flex; justify-content:center; } 希望这就是您正在寻找的🥶🥶🥶🥶🥶🥶

回答 1 投票 0

Chart.js:有没有办法根据数字图例的项目制作具有固定高度和可变宽度的图表

我想知道如果图例中的项目数量与其初始大小不匹配,是否有办法使图表的宽度增加 我尝试了很多不同的设置和方法,例如

回答 1 投票 0

包装类的 CSS 背景不起作用

我正在尝试修改Drupal菜单:page.tpl.php 我正在尝试修改Drupal菜单:page.tpl.php <?php if ($main_menu): ?> <div id="navigation-wrapper"> <div id="navigation"> <nav id="main-menu" role="navigation" tabindex="-1"> <?php // This code snippet is hard to modify. We recommend turning off the // "Main menu" on your sub-theme's settings form, deleting this PHP // code block, and, instead, using the "Menu block" module. // @see https://drupal.org/project/menu_block print theme('links__system_main_menu', array( 'links' => $main_menu, 'attributes' => array( 'class' => array('links', 'inline', 'clearfix'), ), 'heading' => array( 'text' => t('Main menu'), 'level' => 'h2', 'class' => array('element-invisible'), ), )); ?> </nav> <?php print render($page['navigation']); ?> </div> </div> <?php endif; ?> CSS 是: #navigation-wrapper{ overflow:hidden; width:100% background:#ff6005; } #navigation{ width:950px; margin:0 auto; background:#ff6005; } #navigation ul li { display:inline; padding:5px 10px 6px 10px; } 但我的输出仅产生 div 的背景颜色navigation!我期待一个覆盖整个宽度的背景颜色。我的 CSS 有什么问题 > #navigation-wrapper { overflow: hidden; width: 100%; background: #ff6005; } 宽度后您错过了 ;。

回答 1 投票 0

使用ggplot自定义堆叠条之间的空间[关闭]

我测量了两天不同的治疗情况,并将它们放入堆叠的条形图中。现在我想要相同处理(2 个不同天)的两个堆叠条形,彼此更接近。所以我想要

回答 1 投票 0

为什么我的网页宽度超过了设备宽度

我正在尝试构建一个网页,由于某种原因,当我测试页面的响应能力时,页面的宽度超出了设备的宽度。 我尝试删除代码的各个部分和唯一的

回答 1 投票 0

如何使用 HTML / CSS 将宽度设置为移动屏幕尺寸

我正在开发一个网站注册页面。 if(strpos($_SERVER['HTTP_USER_AGENT'], 'Android') !== false) 有了上面的陷阱,我将页面定向到一个单独的移动页面,问题就开始了......

回答 2 投票 0

将图像放置在浏览器100%宽度和100%高度的div中

嗨,这个问题确实很简单,但无法弄清楚。 我想用图像填充浏览器,以便无论用户在浏览器中设置大小,我的图像都会填充内容。 我也需要

回答 5 投票 0

图像标题宽度与图像相同

如何使图像标题宽度与图像相同?现在我有以下代码: 这是标题。 &l... 如何使图像标题宽度与图像相同?现在我有以下代码: <div class="image"> <img src="foo.jpg" alt="" /> <div>This is the caption.</div> </div> 我已经尝试了很多东西(浮动、绝对定位等),但如果标题很长,它总是使 div 变宽而不是多行。问题是我不知道图像的宽度(或标题的长度)。解决这个问题的唯一方法是使用表吗? 所以问题是你不知道img会有多宽,而img的标题可能会超出img的宽度,在这种情况下你想将标题的宽度限制为img的宽度. 在我的例子中,我在父元素上应用了 display:table,并在标题元素上应用了 display:table-caption 和 caption-side:bottom,如下所示: <div class="image" style="display:table;"> <img src="foo.jpg" alt="" /> <div style="display:table-caption;caption-side:bottom;">This is the caption.</div> </div> 您可以应用 display:table; 和任意初始宽度,例如。 width:7px; 到父块,如 figure ,一切都会按预期工作! 这是一个现场演示: http://jsfiddle.net/blaker/8snwd/ 此解决方案的限制是 IE 7 及更早版本不支持 display:table;,而 IE 8 要求您的文档类型为 !DOCTYPE。 来源: http://www.lifeathighroad.com/web-development/forcing-to-wraps-to-the-width-of-an-image-using-css-only/ W3Schools(由于 stackoverflow 对代表人数少于 10 人的 2 链接限制,无法发布链接) 如果问题是标题太长,您可以随时使用 div.image { width: 200px; /* the width you want */ max-width: 200px; /* same as above */ } div.image div { width: 100%; } 并且标题将保持静态。另外,标签名称是img,而不是image。 或者,如果你想检测图像宽度,你可以使用 jQuery: $(document).ready(function() { var imgWidth = $('.image img').width(); $('.image div').css({width: imgWidth}); }); 这样,您就可以获得图像宽度,然后将标题宽度设置为它。 正确添加字幕的唯一方法是将图像和标题包含在由具有 table、table-row 和 table-cell css 属性的 span 元素构造的表格中。 任何其他方法(包括 HTML5 图形标签)都会导致宽度不匹配或导致不必要的换行。 如果您的方法必须在非 CSS3 浏览器中工作,那么表格可能是最好的选择。 扩展上述内容,我使用此 jQuery 代码片段来检查代码中具有标题的所有图像,并将标题宽度设置为与前一个图像的宽度相匹配。所以如果 HTML 是这样的: <img src="blah" /><figcaption>this is the first caption</figcaption> <img src="blah2" /><figcaption>this is the second caption</figcaption> 然后使用这个 jQuery: $("figcaption").each(function () { $(this).css("width", $(this).prev("img").width()) }); 您可以尝试设置图像div包装器display:inline-block http://jsfiddle.net/steweb/98Xvr/ 如果标题很长,唯一的解决办法就是设置固定宽度,或者通过js设置.image div宽度。我正在尝试考虑一个纯 css 解决方案,但我认为这是一个艰巨的挑战:) 关键是将图像视为具有一定的宽度和一定的长度。在下面的示例中,我检查了图像的宽度为 200 像素。然后将标题视为内联块。 HTML: <div style="width:200px;"> <img src="anImage.png" alt="Image description"/> <div class="caption">This can be as long as you want.</div> </div> CSS: .caption { display: inline-block; } 您还可以通过将上面的 css 替换为以下内容之一,将内联块替换为左对齐、右对齐或拉伸到精确图像宽度的文本: .caption { /* text-align: left; */ /* text-align: right; */ text-align: justify; }

回答 7 投票 0

Swiperjs 在网格内时出现 100% 宽度错误

我在网格内使用 SwiperJS 时遇到问题。当我将 Swiper 包装器放入 with display: grid 时,包装器溢出 100%。我提供了 JSFiddle 示例的链接。 ...

回答 2 投票 0

chartjs中如何控制条形图的宽度?

我使用chartjs 的条形图中的条形太宽了。我怎样才能让它们变薄? 这是我的代码 const ctx = document.getElementById('myChart'); 新图表(ctx,{ 类型:'酒吧', 数据: { 实验室...

回答 1 投票 0

Flutter:让 TextField(或任何小部件)仅占用最小的必要空间

我是 Flutter 新手,来自 React 和 Vue。 我正在尝试制作一个简单的小部件,用于输入小时和分钟。我认为结果很好,尽管我有小部件 stret 的问题...

回答 1 投票 0

$(window).width() 返回的宽度与 Chrome DevTools 指示的宽度不同

当$(window).width() == 768时,会执行alert()。但在 Chrome DevTools 中,当宽度为 786px 时,实际上会发生这种情况。为什么以及如何让我的 JS 在 768px 而不是 786 处触发?

回答 2 投票 0

装饰颤动中的容器渐变宽度

我有一个带有渐变 BoxDecoration 的容器。我想要实现的是减少渐变的宽度,就像边框一样,这样它就可以是一条小细线。以下是我的续...

回答 2 投票 0

文本区域宽度自动调整大小

当我在文本区域内写入时,我想自动调整文本区域的宽度,并设置最大宽度,就像这段代码对输入所做的那样。 http://jsbin.com/ahaxe 有可能吗?

回答 4 投票 0

获取div元素的宽度

HTML: 发帖 CSS: #header #postanad { 位置:绝对; 顶部:50 像素; 左:250 像素; 背景:#000 url(postad.gif) 重复...

回答 5 投票 0

容器宽度在较小的屏幕上无法保持 100%

我正在尝试制作一个具有响应式 UI 的简单应用程序登录页面,但我在使用 chrome DevTools 和理解每个容器宽度的行为方面遇到了很多困难。我有每个

回答 1 投票 0

Angular Material Mat-根据最长选项宽度选择宽度

我有一个带有选项的垫选择,我希望将其内联设置为文本,并且下拉列表的长度与最长的选项一样长。我可能可以用 js / css vanilla 风格做一些黑客行为,但是

回答 4 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.