响应式语义UI响应网格,列,行 [英] Responsive Semantic UI React Grid, Columns, Rows

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

问题描述

我无法使Semantic UI React网格充分响应,至少以我想要的方式响应桌面,平板电脑和移动设备。

我在Grid Columns中显示以下三个组件。

 从'react'导入React,{Component}; 
从'react-redux'导入{connect};
从'semantic-ui-react'中导入{Grid,Header}
从'../../components/Home/GetJobs'导入GetJobs;
从'../../components/Home/PostForm'中导入PostForm;
从'../../components/Home/Feed'导入Feed;
从'../../components/Home/Articles'中导入文章;
import'./home.css'

class Home扩展组件{
render(){
return(
< Grid id =home stackable columns = {3}>
< Grid.Row>
< Grid.Column>
< Header> Articles< / Header>
< >
< /Grid.Column>
< Grid.Column>
< Feed />
< /Grid.Column>
< Grid.Column>
< Header>作业< /页眉>
< GetJobs />
< /Grid.Column>
< /Grid.Row>
< / Grid>

}
}

导出默认主页;

从桌面移动到移动时,这些列可以正确堆叠。它从3列到1列。但是,在平板电脑尺寸下,3列只是更紧密地安装,而不是在屏幕上有2列,而1则在下面堆叠。

查看组件
组件的平板视图



理想情况下,我希望Feed和Jobs在进入屏幕时保持从桌面到平板电脑的大小,以及从平板电脑到移动设备时,Feed的顶部,下面的Jobs和底部的Articles。

有关如何让网格回应如此的任何帮助。

解决方案

stackable prop仅在移动设备上折叠列,不同设备上的宽度,您应该使用响应式道具。您也可以尝试使用 only 颠倒了。我做了一个例子,说明如何做到这一点。

 < Grid> 
< Grid.Column only ='computer'computer = {5}>
<标题>文章< /标题>
< /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>
< / Grid>


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;

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.

View Component Tablet View of Component

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 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响应网格,列,行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆