[英]How can I switch between content on the same page using HTML/CSS/Javascript?
I want to show different content for when the user switches between different month/year options within the same page.当用户在同一页面内的不同月份/年份选项之间切换时,我想显示不同的内容。 eg I want to show the user events for the month of March 2021 if he /she chooses that option.
例如,如果他/她选择该选项,我想显示 2021 年 3 月的用户事件。 Attached is the screenshot for reference of how I want the UI to look like.
附件是我希望 UI 看起来如何的屏幕截图,以供参考。
As far as I know, doing this with vanilla html,css,js is pretty hard.据我所知,用香草 html,css,js 做这件事是相当困难的。 What you can do is using a
<div>
for every month and use css to set all of them to display: none
except the one that should be shown.您可以做的是每个月使用一个
<div>
并使用 css 将所有这些设置为display: none
。 Then you could attach an onclick
listener to your two arrow keys.然后,您可以将
onclick
侦听器连接到您的两个箭头键。 With javascript you can then make your current month <div>
hidden and show your next month with display: block
.使用 javascript 您可以隐藏当前月份
<div>
并使用display: block
下个月。 You have to watch out that all your seperate month containers are position: absolute
at exactly the same place.您必须注意所有单独的月份容器都是
position: absolute
在同一个地方。
Watch out, this is a really not ideal solution especially if you have a lot of containers.请注意,这确实不是一个理想的解决方案,尤其是在您有很多容器的情况下。
The proper way to do this would be using something like ReactJS
or you could also try Ajax
.正确的方法是使用
ReactJS
之类的东西,或者您也可以尝试Ajax
。 Both allow you to change part of your website without having to reload it completely.两者都允许您更改网站的一部分,而无需完全重新加载。
This is just how you can do it.这就是你可以做到的。 Don't expect anyone on the forum here to do the work for you.
不要指望论坛上的任何人为您完成工作。 If you have specific questions or problems, feel free to ask but this is not a platform to get free workers.
如果您有具体的问题或问题,请随时提出,但这不是获得免费工人的平台。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.