html移动端底部导航菜单按钮(仿各大app底部)

不多说直接上代码:

<!DOCTYPE html>
<meta name="viewport"
      content="width=device-width,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0,user-scalable=no">
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>底部导航实现点击切换页面</title>
    <style>
        * {
            box-sizing: border-box;
        }

        .menu {
            display: block;
            position: fixed;
            bottom: 0;
            width: 100%;
            height: 150px;
            color: white;
            padding-top: 10px;
            border-top: 1px solid #eee;
            background-color: #010791;
        }

        .subMenu {
            width: 25%;
            float: left;
            cursor: pointer;
        }

        .menu_name {
            height: 30px;
            width: 100%;
            line-height: 30px;
            font-size: 40px;
        }

        .active {
            color: #01cd3f;
        }

        .text-center {
            text-align: center
        }

        button{
            border-style: none;

        }
    </style>
    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
</head>
<body onload="initSize()" onresize="initSize()">
<!--content-->
<div id="content"></div>
<!--bottom-->
<div id="menu" class="menu">
    <div id="one" class="subMenu text-center" data-src="radar.html">
        <span class="glyphicon glyphicon-edit btn-lg" style="font-size:40px;"></span>
        <div class="menu_name">考核</div>
    </div>
    <div id="two" class="subMenu text-center" data-src="cha.html">
        <span class="glyphicon glyphicon-list btn-lg" style="font-size:40px;"></span>
        <div class="menu_name">特征</div>
    </div>
    <div id="three" class="subMenu text-center" data-src="advise.html">
        <span class="glyphicon glyphicon-comment btn-lg" style="font-size:40px;"></span>
        <div class="menu_name">建议</div>
    </div>
    <div id="four" class="subMenu text-center" data-src="position.html">
        <span class="glyphicon glyphicon-sort-by-attributes-alt btn-lg" style="font-size:40px;"></span>
        <div class="menu_name">排名</div>
    </div>
</div>

</body>
<script>
    //$(function () {});
    $(document).ready(function () {
        //点击事件
        $("div .subMenu").click(function () {

            $(".active").removeClass("active");

            // 添加新状态
            $(this).addClass("active");
            //content根据点击按钮加载不同的html
            var page = $(this).attr("data-src");
            if(page){
                $("#content").load(page)
            }
        });

        // 自动点击第一个菜单
        $("div .subMenu")[0].click();
    });

    /*content高度*/
    function initSize() {
        var height = $(window).height() - $("header").height() - $("#description").height() - $("#menu").height();
        $("#content").height(height + "px");
    }
</script>

</html>
<div id="one" class="subMenu text-center" data-src="radar.html">
        <span class="glyphicon glyphicon-edit btn-lg" style="font-size:40px;"></span>
        <div class="menu_name">考核</div>
    </div>

//data-src="radar.html"中改成自己小的html,其他的css样式的设置,自己动手吧

 

### 如何在 React 中为移动设备创建底部导航菜单 要在 React 项目中实现移动端底部菜单功能或样式,可以利用 `@react-navigation/bottom-tabs` 提供的支持。以下是具体方法: #### 使用 Bottom Tab Navigator 实现底部菜单 通过安装并配置 `@react-navigation/bottom-tabs` 库,可以在应用中轻松集成底部导航栏。 1. **安装依赖** 需要先安装必要的库来支持底部标签导航: ```bash npm install @react-navigation/native npm install react-native-screens react-native-safe-area-context npm install @react-navigation/bottom-tabs ``` 2. **设置基础结构** 下面是一个简单的例子,展示如何使用 `createBottomTabNavigator` 来定义底部菜单: ```javascript import * as React from 'react'; import { NavigationContainer } from '@react-navigation/native'; import { createBottomTabNavigator } from '@react-navigation/bottom-tabs'; // 导入各个页面组件 function HomeScreen() { return <></>; } function SettingsScreen() { return <></>; } const Tab = createBottomTabNavigator(); export default function App() { return ( <NavigationContainer> <Tab.Navigator> <Tab.Screen name="Home" component={HomeScreen} /> <Tab.Screen name="Settings" component={SettingsScreen} /> </Tab.Navigator> </NavigationContainer> ); } ``` 3. **自定义图标和标题** 可以为每个选项卡指定图标以及调整其外观。例如: ```javascript import Icon from 'react-native-vector-icons/Ionicons'; <Tab.Navigator screenOptions={({ route }) => ({ tabBarIcon: ({ focused, color, size }) => { let iconName; if (route.name === 'Home') { iconName = focused ? 'home' : 'home-outline'; } else if (route.name === 'Settings') { iconName = focused ? 'settings' : 'settings-outline'; } return <Icon name={iconName} size={size} color={color} />; }, })} tabBarOptions={{ activeTintColor: 'tomato', inactiveTintColor: 'gray', }} > <Tab.Screen name="Home" component={HomeScreen} /> <Tab.Screen name="Settings" component={SettingsScreen} /> </Tab.Navigator>; ``` 4. **动态路由跳转** 如果需要在一个独立按钮上触发导航到特定屏幕的操作,则可参考以下方式: ```javascript import * as React from 'react'; import { Button } from 'react-native'; import { useNavigation } from '@react-navigation/native'; function GoToButton({ screenName }) { const navigation = useNavigation(); return ( <Button title={`Go to ${screenName}`} onPress={() => navigation.navigate(screenName)} /> ); } ``` 上述代码片段展示了如何通过 `useNavigation()` 自动获取导航实例,并调用 `navigate` 方法完成页面切换[^1]。 5. **优化布局与样式** 为了使界面更加美观和谐统一,在设计过程中还可以引入 Flexbox 布局技术。它允许开发者灵活控制容器内的子项排列规则,从而适应不同分辨率下的显示需求[^3]。 最后一步就是根据实际业务逻辑完善各分细节处理,比如加载数据、错误提示等内容填充工作。 ---
评论 18
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值