首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在弹出模式中将图像移至中心

在弹出模式中将图像移至中心
EN

Stack Overflow用户
提问于 2021-03-19 08:06:19
回答 1查看 48关注 0票数 1

我使用的是reactjs-popup库中的一个弹出模式组件。我想将图表图像(一个图像中的三个图表)放在弹出窗口的中心,但是像align-self这样的属性似乎不适合我。我还能尝试什么呢?

代码语言:javascript
复制
export default () => (
  <Popup
    trigger={<button className="button"> Guide </button>}
    modal
    nested
  >
    {(close: any) => (
      <div className="modal">
        <button className="close" onClick={close}>
          &times;
        </button>
        <div className="header"> Guide </div>
        <div className="content">
          {' '}
          {/* <img src={chart} alt="charts" className="charts"/> */}
          <img src={img} alt="charts" className="charts" />
          What is overfitting?
          <br />
          What is underfitting?
          This example demonstrates the problems of underfitting and overfitting and how we can use linear regression with polynomial features to approximate nonlinear functions.
        </div>
        <div className="actions">
        </div>
      </div>
    )}
  </Popup>
);

它看起来是这样的:

css

代码语言:javascript
复制
.modal {
    font-size: 12px;
    border-color: black;
    border-style: solid;
  }
  .modal > .content {
    width: 100%;
    padding: 10px 5px;
    background-color: white;
  }
  .modal > .actions {
    width: 100%;
    padding: 10px 5px;
    margin: auto;
    text-align: center;
    background-color: white;
  }
  .charts {
    align-self: center;
  }

我还想把文本what's overfitting移到中间的图片下面。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-03-19 08:13:53

display: flex;添加到.modal > content的css类中。此外,为了使项目居中对齐,您需要在同一个css类中设置flex-direction: column;align-items: center

我还建议您在本MDN article中阅读有关flex对齐的概念。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66700845

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档