L'image dépasse l'écran et vous devez balayer vers la gauche et la droite pour voir comment la réparer

问:
<template>
  <div id="app">
    <img src="@/assets/pic_0.png" alt="" class="pageone" />
    <div class="overlay">
      <!-- 输入框 -->
      <el-input placeholder="请输入邮箱地址" v-model="email" class="input"></el-input>
      <!-- 按钮 -->
      <el-button type="primary">限时免费订阅</el-button>
      <!-- 文字链接 -->
      <el-link type="primary" @click="example" class="link" :underline="false">查看样例>></el-link>
    </div>
  </div>
</template>

<script>
import axios from "axios";
export default {
  // setup() {

  // },
  data() {
    return {
      email: this.email,
    };
  },
  methods: {
    subscribe() {
      if (this.email != undefined && this.email != '') {
        axios
          .get(
            `https://gateway.caixin.com/api/edm/edm/subscriber?email=${this.email}&subList=16`
          )
          .then((resppnse) => {
            this.$message.success("订阅成功,3秒后将跳转财新网首页…")
            setTimeout(() => {
              window.location.href = 'https://www.caixin.com/'
            }, 3000);
          })
          .catch((error) => { this.$message.error("订阅失败") });
      } else {
        this.$message.error("请输入邮箱")
      }
    },
    example() {
      window.location.href = "http://download.caixin.com/upload/caixinzhiku211.pdf";
    },
  },
};
</script>


<style lang="less" scoped>
#app{
  position: relative;
  .pageone{
    position: absolute;
  }这里的图片超过了屏幕需要左右滑动才能看见怎么修复
回答:
要修复图片超出屏幕需要左右滑动才能看见的问题,您可以尝试以下方法:

1. 响应式设计:使用CSS媒体查询,根据屏幕宽度设置不同的样式。例如,在屏幕较小的情况下,可以将图片的宽度设置为100%以适应屏幕大小,从而确保图片始终完全显示在屏幕上。

```css
@media screen and (max-width: 768px) {  /* 根据需要修改屏幕宽度阈值 */
  .pageone {
    width: 100%;
    height: auto;
    left: 0;
    right: 0;
    margin-left: auto;
    margin-right: auto;
  }
}
```

2. 水平滚动条:将外层容器的`overflow-x`属性设置为`auto`,这会在内容超出容器宽度时显示一个水平滚动条,用户可以通过滚动来查看完整的内容。

```css
#app {
  overflow-x: auto;
}
```

这样,当图片的宽度超出屏幕宽度时,用户可以通过水平滚动条来查看完整的图片内容。

请注意,根据您的具体项目和UI设计,您可能需要调整代码中的样式细节来适应您的需求。

おすすめ

転載: blog.csdn.net/kuang_nu/article/details/132672280