[英]Image not overflowing in html page
I would like to know if it's possibile to trasform a web page like this: 我想知道是否可以像这样转换网页:
to this: 对此:
? ?
Some code used, under development, to obtain first image: 正在开发中的一些代码用于获取第一张图片:
/** CSS **/
div.Testata35, div.Testata25, div.Testata70Inner, div.Testata29Inner, div.Testata15Inner {
background-color: #C0C0C0;
float: left;
}
div.Testata35, div.Testata25 {
margin-bottom: 0.2%;
margin-right: 1%;
margin-top: 0.2%;
padding-bottom: 0.2%;
padding-left: 1%;
padding-top: 0.2%;
}
div.Testata35 {
width: 35.5%;
}
div.Testata25 {
width: 23%;
}
div.Valore35, div.Valore25 {
float: left;
margin-top: 0.2%;
overflow: auto;
padding-bottom: 0.2%;
padding-left: 1%;
padding-top: 0.2%;
}
div.Valore35 {
margin-right: 2.5%;
width: 34%;
}
div.Valore25 {
margin-right: 1%;
width: 23%;
}
<!-- HTML -->
<div class="ClrOvFlw">
<div class="PrimaSx">
<div class="ClrOvFlw">
<div id="T1" class="Testata35">Modello</div>
<div id="T1A" class="Testata35">Linea</div>
<div id="T2" class="Testata25A">
<div style="clear: left; float: left; width: 70%;">Standard</div>
<div style="clear: right; float: right; width: 20%; z-index: 1; overflow: auto;">
<img id="V25BImg" src="./FotoNorma/standard01-ITA.jpg" alt="Marchio Normativa">
</div>
</div>
<div class="ClrOvFlw">
<div id="V1" class="Valore35">BELLARIA</div>
<div id="V1A" class="Valore35">MODULAR</div>
<div id="V2" class="Valore25A">EN ISO 20345:2011</div>
</div>
</div>
<div class="Valore25B">
</div>
</div>
<div class="ClrOvFlw">
<div id="T3" class="Testata35">Codice Articolo</div>
<div id="T4" class="Testata35">Protezione</div>
<div id="T5" class="Testata25">Disponibilità a Magazzino</div>
</div>
<div class="ClrOvFlw">
<div id="V3" class="Valore35">83297-07LL</div>
<div id="V4" class="Valore35">S1P SRC</div>
<div id="V5" class="Valore25">
<img id="V5Img" src="FotoMagazzino\maga2-ITA.jpg" alt="Disponibilità">
</div>
</div>
As you can see, I've tried some stuff to achieve the result shown in the second image but with no success. 如您所见,我已经尝试了一些方法来实现第二幅图中显示的结果,但是没有成功。 As side note: I'm not a professional HTML/CSS developer so my "code" is not written as the best practice hints.
附带说明:我不是专业的HTML / CSS开发人员,因此我的“代码”并未写成最佳实践提示。
EDIT : 编辑 :
As suggested by many of you, I've update my code in this way: 正如许多人建议的那样,我已经通过以下方式更新了代码:
<div class="ClrOvFlw">
<div id="T1" class="Testata35">Modello</div>
<div id="T1A" class="Testata35">Linea</div>
<div id="T2" class="Testata25A">
<div style="float: left; clear: left;">Standard</div>
<div class="Valore25B" style="float: right; clear: right; position: relative;">
<img id="V25BImg" src="./FotoNorma/standard01-ITA.jpg" alt="Marchio Normativa" style="position: absolute; display : block; width: 100%; height: 100%;">
</div>
</div>
</div>
Same CSS as above. 与上述相同的CSS。 My results:
我的结果:
EDIT 2: 编辑2:
following suggestions of Fils I've updated my code as follows: 遵循Fils的建议,我已如下更新代码:
<div id="T2" class="Testata25A">
<div style=" clear: left; float: left;">Standard</div>
<div class="Valore25B" style="position: relative; overflow: auto;">
<img id="V25BImg" src="./FotoNorma/standard01-ITA.jpg" alt="Marchio Normativa" style="position: absolute; right: 0px;overflow: visible; height: 100px;">
</div>
</div>
getting this result: 得到这个结果:
I guess that I'm doing something wrong in following your hints folks. 我想我按照您的提示做错了。
You could use position:absolute; 您可以使用position:absolute; on that image if you can gurantee that there is always enough space that the whole image will be displayed:
如果可以确保在该图像上保留总是有足够的空间可以显示整个图像:
div#V25BImg{ display:block; position:absolute; width:[WIDTH]px; height:[HEIGHT]px; }
Also you might need to add position:relative; 另外,您可能需要添加position:relative; on the parent of the image to ensure that the absolute positioned element will be placed on the correct part of your page.
在图片的父元素上,以确保将绝对定位的元素放置在页面的正确部分上。
Set the image holder to position absolute: 将图像支架设置为绝对位置:
This is untested but should give you an idea 这未经测试,但应该给您一个想法
<div style="position: absolute; top: 0; right: 0; width: 20%; z-index: 1; overflow: auto;">
<img id="V25BImg" src="./FotoNorma/standard01-ITA.jpg" alt="Marchio Normativa">
</div>
If you position your img
absolutely, it will ignore wrapping. 如果您将
img
定位绝对,它将忽略换行。
div #V5 img {
position:absolute;
right:0px;
}
Maybe you can do by adding position: relative;
也许可以通过添加
position: relative;
in the div wrapping the image, and adding 在div中包装图片,然后添加
position: absolute;
top: 25px;
margin-left: 10px;
to the image. 图片。 Your code should look like this,
您的代码应如下所示:
<div style="width: 20%;position: relative;">
<img id="V25BImg" src="logo.png" alt="Marchio Normativa" data-pin-nopin="true" style="position: absolute;top: 25px; margin-left: 10px;
">
</div>
check this out https://jsfiddle.net/1w772kgg/1/ 检查一下https://jsfiddle.net/1w772kgg/1/
If you need a correct solution, do not use absolute positioning unless absolutely necessary. 如果需要正确的解决方案,除非绝对必要,否则不要使用绝对定位。 A floating element can be floating out from its parent container, if:
在以下情况下,浮动元素可以从其父容器中浮动出来:
overflow:auto
, and overflow:auto
,并且 clear
, too wide line, overflow:hidden
block element etc.) clear
,太宽的行, overflow:hidden
块元素等) See float rules here. 请参阅此处的浮动规则。
Try provide this conditions. 尝试提供此条件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.