[英]table keeps resizing not overflow
I'm trying to make my table overflow on the x axis instead of resizing once it gets past 900px browser width. 我试图使我的表在x轴上溢出,而不是在超过900px浏览器宽度时重新调整大小。
Here is my code: 这是我的代码:
<div className='jobTableTop'>
<table className='jobsTable'>
<tbody>
<tr className='jobsTableHeader'>
<td style={{"color": "lightgray"}}>BY</td>
<td style={{"color": "lightgray"}}>JOB TITLE</td>
<td style={{"color": "lightgray"}}>OPTION</td>
<td style={{"color": "lightgray"}}>LOCATION</td>
<td style={{"color": "lightgray"}}>WAGE</td>
<td style={{"padding-top": "0px"}}></td>
</tr>
{this.props.dataToShow.map(function (item, index) {
return (
(index >= minItem && index <= maxItem) ?
<tr key={item.id}>
<td>{item.company}</td>
<td>{item.title}</td>
<td>{item.option}</td>
<td>{item.location}</td>
<td>{item.wage}</td>
<td style={{"padding-top": "0px"}}>
<a href={'/job-detail/' + item.id}>
<Button className={classes.button} style={{"font-size": "20px"}} raised color="accent">
Apply
</Button>
</a>
</td>
</tr>
:
''
)})}
</tbody>
</table>
</div>
that is the jsx/html code 那是jsx / html代码
here is the css: 这是CSS:
@media screen and (max-width: 900px){
.jobsTable{
overflow: hidden;
}
}
.jobsTable tr {
border-bottom: 1px solid lightgray;
display: flex;
}
.jobsTable tr td {
width: 16.6%;
height: 40px;
padding-top: 20px;
font-size: 20px;
vertical-align: middle;
color: black;
}
so when it goes under 900px i want it so that theres a scroll bar instead of the table going smaller no matter what i seem to do nothing makes it do this. 所以当它低于900px时,我想要它,以便无论我似乎什么都不做,有一个滚动条而不是表格变小,使它做到了这一点。 Im trying to make it mobile compatible without making a separate version of the site.
我试图使它与移动设备兼容,而无需制作该网站的单独版本。
edit changed: 编辑已更改:
all i changed was this. 我只改变了这个。
.jobTableTop {
width: 100%;
overflow-x: scroll;
overflow-y: hidden;
}
i have to make the webpage around 750px instead of 900px. 我必须将网页设置为750px而不是900px。 how would i achieve said goal.
我将如何实现上述目标。
All you need to need to do little change in your CSS code as below. 您所需要做的只是在CSS代码中做一些改动,如下所示。 Additionally, you can also define
width: 100%;
此外,您还可以定义
width: 100%;
if you want to make the full available space used by the table. 如果要腾出表使用的全部可用空间。 I have also added this code in CSS
我也在CSS中添加了此代码
@media screen and (max-width: 900px){
.jobsTable{
width: 100%;
overflow-x: auto;
}
}
fixed code section not being all in grey -Andy 固定代码部分不是全部为灰色-Andy
我通过将360px的百分比提高到大约300%并从那里解决所有其他尺寸的屏幕来解决上述问题
you must use @media
media query and write your css
like this: 您必须使用
@media
媒体查询并像这样编写css
:
@media screen and (max-width: 900px){
.jobsTable{
width: 100%;
overflow-y: hidden;
overflow-x: auto;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.