CSS样式未完全应用

huangapple go评论101阅读模式
英文:

CSS Style not being applied completely

问题

我正在尝试通过使用 right : -80px; 来裁剪嵌套在 iframe 中的网站的右侧。一切似乎都正常,但右侧的裁剪没有生效。

我已经尝试过:

  • rightleft 更改为 margin-rightmargin-left
  • 通过按 Ctrl+F5 来执行“完全刷新”浏览器
  • 尝试将值从 -80px 更改为不同的值,以查看是否有效
  • 使用 Edge 和 Firefox 进行测试
英文:

I am trying to crop the right side of the embedded website within the iframe with right : -80px;. Everything seems to work but the cropping of the right side.

  1. <html lang="en">
  2. <body>
  3. <style>
  4. #div-id{
  5. border : 2px solid blue;
  6. width : 600px;
  7. height : 800px;
  8. position : relative;
  9. overflow : hidden;
  10. }
  11. #iframe-id{
  12. position : absolute;
  13. top : -160px;
  14. right : -80px;
  15. left : -25px;
  16. width : 620px;
  17. height : 450vh;
  18. }
  19. </style>
  20. <div id="div-id">
  21. <iframe title="example" src="https://example.org" id="iframe-id" scrolling="yes"></iframe>
  22. </div>
  23. </body>
  24. </html>

I've tried to:

  • change the right and left to margin-right and margin-left
  • "Full"-refreshed the browser via ctrl+F5
  • Changed the value from -80px to many different things to see if it is working at all
  • Used Edge and Firefox for testing

答案1

得分: 0

只拿走权利,因为你想向左走。

  1. <style>
  2. * {
  3. margin:0;
  4. padding:0;
  5. }
  6. body,html {
  7. overflow:hidden;
  8. }
  9. #div-id{
  10. border: 2px solid rgb(255, 0, 0);
  11. width: 40%;
  12. height: 85%;
  13. position: relative;
  14. overflow: hidden;
  15. }
  16. #iframe-id{
  17. position: absolute;
  18. top: -160px;
  19. left: -80px;
  20. width: 620px;
  21. height: 450vh;
  22. }
  23. </style>
  24. <div id="div-id">
  25. <iframe title="example" src="https://example.org" id="iframe-id" scrolling="yes"></iframe>
  26. </div>
  27. </body>
  28. </html>
英文:

Just take away the right because you want to go left.
<html lang="en">
<body>

  1. &lt;style&gt;
  2. * {
  3. margin:0;
  4. padding:0;
  5. }
  6. body,html {
  7. overflow:hidden;
  8. }
  9. #div-id{
  10. border: 2px solid rgb(255, 0, 0);
  11. width: 40%;
  12. height: 85%;
  13. position: relative;
  14. overflow: hidden;
  15. }
  16. #iframe-id{
  17. position: absolute;
  18. top: -160px;
  19. left: -80px;
  20. width: 620px;
  21. height: 450vh;
  22. }
  23. &lt;/style&gt;
  24. &lt;div id=&quot;div-id&quot;&gt;
  25. &lt;iframe title=&quot;example&quot; src=&quot;https://example.org&quot; id=&quot;iframe-id&quot; scrolling=&quot;yes&quot;&gt;&lt;/iframe&gt;
  26. &lt;/div&gt;
  27. &lt;/body&gt;
  28. &lt;/html&gt;

huangapple
  • 本文由 发表于 2023年7月13日 22:05:52
  • 转载请务必保留本文链接:https://go.coder-hub.com/76680292.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定