响应式语义 UI React 网格、列、行

2023-07-31前端开发问题
5

本文介绍了响应式语义 UI React 网格、列、行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我无法让 Semantic UI React 网格完全响应,至少以我想要的方式响应桌面、平板电脑和移动设备.

I'm having trouble making Semantic UI React grid fully responsive, at least respond the way I want for Desktop, Tablet and Mobile.

我在网格列中呈现以下三个组件.

I have following three components which I am rendering in Grid Columns.

import React,{ Component } from 'react';
import { connect } from 'react-redux';
import { Grid, Header } from 'semantic-ui-react'
import GetJobs from '../../components/Home/GetJobs';
import PostForm from '../../components/Home/PostForm';
import Feed from '../../components/Home/Feed';
import Articles from '../../components/Home/Articles';
import './home.css'

class Home extends Component {
  render() {
    return(
      <Grid id="home" stackable columns={3}>
        <Grid.Row>
          <Grid.Column>
            <Header>Articles</Header>
            <Articles/>
          </Grid.Column>
          <Grid.Column>
            <Feed/>
          </Grid.Column>
          <Grid.Column>
            <Header>Jobs</Header>
            <GetJobs/>
          </Grid.Column>
        </Grid.Row>
      </Grid>
    )
  }
}

export default Home;

从桌面设备转移到移动设备时,列可以正确堆叠.它从 3 列变为 1 列.但是,对于平板电脑大小,3 列只是更紧密地安装,而不是在屏幕上有 2 列,1 列堆叠在下方.

The columns stack properly when going from desktop to mobile. It goes from 3 to 1 column. However, at tablet size, the 3 columns are just fitted more tightly instead of having 2 columns on the screen, and 1 being stacked below.

查看组件组件的平板视图

理想情况下,我希望在从台式机切换到平板电脑大小以及从平板电脑切换到移动设备时,Feed 和 Jobs 留在屏幕上,Feed 位于顶部,Jobs 位于下方,Articles 位于底部.

Ideally, I'd like Feed and Jobs to stay on the the screen when going from Desktop to Tablet size, and when going from Tablet to Mobile, have Feed on top, Jobs below, and Articles at the bottom.

对于如何让这个网格做出这样的响应,我们不胜感激.

Any help is appreciated on how to get this grid to respond like this.

推荐答案

stackable prop 仅在移动设备上折叠列,为了精确控制不同设备上的宽度,您应该使用 响应 道具.您也可以尝试使用 only 和 反向.我做了一个例子来说明如何做到这一点.

stackable prop collapses columns only on mobile device, for precise control of widths on diffent devices you should use responsive props. You can also try to play with only and reversed. I made an example that shows how to do this.

<Grid>
  <Grid.Column only='computer' computer={5}>
    <Header>Articles</Header>
  </Grid.Column>
  <Grid.Column mobile={16} tablet={8} computer={5}>
    <Feed/>
  </Grid.Column>
  <Grid.Column mobile={16} tablet={8} computer={5}>
    <GetJobs/>
  </Grid.Column>
  <Grid.Column only='mobile tablet' mobile={16} tablet={16}>
    <Header>Articles</Header>
  </Grid.Column>
</Grid>

这篇关于响应式语义 UI React 网格、列、行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

Fatal error: Call to a member function fetch_assoc() on a no
业务场景:使用update语句去更新数据库字段。 原因:update接收值不正确。原来代码: $query = "UPDATE student SET date = now() WHERE id = $id";$result = $mysqli-query($query2) or die($mysqli-error); // 问题出现了在这句 $data = $result-fetch_ass...
2024-12-13 前端开发问题
136

layui 单选框、复选框、下拉菜单不显示问题如何解决?
1. 如果是ajax嵌套了 页面, 请确保 只有最外层的页面引入了layui.css 和 layui.js ,内层页面 切记不要再次引入 2. 具体代码如下 layui.use(['form', 'upload'], function(){ var form = layui.form; form.render(); // 加入这一句});...
2024-11-09 前端开发问题
313

layui要如何改变时间日历布局大小?
问题描述 我想改变layui时间日历布局大小,这个要怎么操作呢? 解决办法 可以用css样式对时间日历进行重新布局,具体代码如下: !DOCTYPE htmlhtmlheadmeta charset="UTF-8"title/titlelink rel="stylesheet" href="../../layui/css/layui.css" /style#test-...
2024-10-24 前端开发问题
271

layui.render怎么控制某一列是否可以编辑
layui.render控制某一列是否可以编辑,先看代码: ,done:function (res, curr, count){//设置查看量那一列的通过status决定是否可以编辑 let tableView = this.elem.next(); layui.each(res.data, function(i, item) { console.log("curr",curr) if (item.sta...
2024-06-11 前端开发问题
326

ExecJS::ProgramError: SyntaxError: 保留字“function"
ExecJS::ProgramError: SyntaxError: Reserved word quot;functionquot;(ExecJS::ProgramError: SyntaxError: 保留字“function)...
2024-04-20 前端开发问题
13

一组可供 Rails 应用程序使用的 CoffeeScript/JavaScript 类和方法
Set of CoffeeScript/JavaScript classes and methods available to rest of Rails app(一组可供 Rails 应用程序使用的 CoffeeScript/JavaScript 类和方法)...
2024-04-20 前端开发问题
13