본문 바로가기
개념/JQuery

JQuery) jQuery Mobile Advanced Grids and Collapsible Panel Example

by kiseno 2025. 3. 4.
728x90
반응형
SMALL
<!DOCTYPE html>
<html>
<head>
    <title>jQuery Mobile Advanced Grids and Panel</title>
    <link rel="stylesheet" href="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
    <script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
    <script src="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
    <style>
        /* 다중열 그리드 테마 */
        .my-grid .ui-block-a { background-color: lightblue; }
        .my-grid .ui-block-b { background-color: lightgreen; }
        .my-grid .ui-block-c { background-color: lightyellow; }
    </style>
</head>
<body>

<div data-role="page" id="mainPage">
    <div data-role="header">
        <h1>Advanced Grids and Panel</h1>
    </div>
    <div data-role="content">

        <!-- 다중별 그리드 레이아웃 -->
        <div class="ui-grid-b my-grid">
            <div class="ui-block-a"><a href="#" data-role="button">별 1</a></div>
            <div class="ui-block-b"><a href="#" data-role="button">별 2</a></div>
            <div class="ui-block-c"><a href="#" data-role="button">별 3</a></div>
            <!-- 추가 별 모양 블록을 여기에 추가할 수 있습니다. -->
        </div>

        <!-- 다중 행 그리드 레이아웃 -->
        <div class="ui-grid-a">
            <div class="ui-block-a"><a href="#" data-role="button">행 1, 열 1</a></div>
            <div class="ui-block-b"><a href="#" data-role="button">행 1, 열 2</a></div>
        </div>
        <div class="ui-grid-a">
            <div class="ui-block-a"><a href="#" data-role="button">행 2, 열 1</a></div>
            <div class="ui-block-b"><a href="#" data-role="button">행 2, 열 2</a></div>
        </div>

        <!-- 기본 접이식 패널 -->
        <div data-role="collapsible">
            <h3>접이식 패널</h3>
            <p>이것은 기본 접이식 패널입니다.</p>
        </div>

    </div>
</div>

</body>
</html>

1. **Grid Layouts**:
   - **Multiple Column Grid**: A three-column grid (`class="ui-grid-b my-grid"`) showcases how to distribute horizontal space among multiple elements. Each block (`ui-block-a`, `ui-block-b`, `ui-block-c`) represents a column, and custom background colors are applied through an additional class (`my-grid`) defined in the `<style>` section. This is a flexible way to create responsive designs that adapt to various screen sizes.
   - **Multiple Row Grid**: Sequential `div` elements with `class="ui-grid-a"` create a grid layout with multiple rows, each containing two columns. This pattern demonstrates how to organize content into a structured grid, enhancing the visual layout and readability on mobile devices.

2. **Collapsible Panel**:
   - A collapsible panel (`data-role="collapsible"`) provides an interactive way to display and hide content. This widget is particularly useful for managing space in mobile interfaces, allowing users to expand sections to read more and collapse them to save space.

3. **Custom Styling**:
   - The document includes custom CSS to differentiate columns within the grid by background color. This not only enhances the visual appeal but also helps to distinguish between different interactive elements or content sections visually.

4. **Interactivity and Mobile Optimization**:
   - jQuery Mobile's framework is utilized to enhance standard HTML elements with mobile-optimized behaviors. For example, links within grid blocks are transformed into styled buttons (`data-role="button"`), and the collapsible panel is automatically enhanced with jQuery Mobile's styles and animations.

### Key Points:
- jQuery Mobile's grid system offers a straightforward approach to creating responsive layouts that adapt to the screen size, ensuring a consistent user experience across devices.
- The collapsible panel widget is a powerful tool for content management in mobile interfaces, allowing for efficient use of space and user-driven exploration of content.
- Custom CSS alongside jQuery Mobile's theming capabilities enables the creation of unique and engaging designs, highlighting the framework's flexibility in tailoring the appearance of web applications to specific design requirements.

### Possible Improvements:
- **Accessibility Enhancements**: Ensure that all interactive components are accessible, including appropriate ARIA roles and labels, especially for dynamic elements like collapsible panels.
- **User Experience (UX) Enhancements**: Implement feedback or visual cues for interactive elements to improve usability. For instance, changing the appearance of buttons when tapped or indicating the expanded/collapsed state of panels more clearly could enhance user interactions.
- **Performance Optimization**: Consider optimizing the application’s performance, especially if integrating with larger frameworks or adding more complex features, to ensure smooth operation on mobile devices.
- **Expanded Grid Features**: Explore more advanced grid configurations, such as nested grids or dynamically adjustable grids based on content or user interaction, to further enhance the layout capabilities.

728x90
반응형
LIST