Design for a mobile webpage layout featuring a carousel-style format

Recently, I've been experimenting with creating a mobile application using PhoneGap and I have some questions about defining the layout.

I am trying to create a single-page layout with side scrolling, similar to a carousel image gallery, but instead of switching images, I want to switch between pages.

My goal is to achieve a carousel-like effect when switching "pages" and I was considering using Bootstrap or Ink for this purpose. I would like each column to act as a different screen, much like the concept explained in an example where red squares represent the visible screen (or column) and blue squares represent the invisible screens (or columns). Each column should "scale" to fill the screen/viewport.

After reading the documentation for both frameworks, I'm unsure how to accomplish this given the column definitions provided.

The default Bootstrap grid system consists of 12 columns, resulting in a container that is 940px wide without responsive features enabled. Once the responsive CSS file is added, the grid adjusts to be either 724px or 1170px wide based on the viewport size. For viewports under 767px, the columns stack vertically.

In Ink, you have three layouts available: S for small, M for medium, and L for large. By default, these correspond to specific screen size intervals:

- Small: below 650 pixels wide
- Medium: between 651 and 960 pixels wide
- Large: above 961 pixels wide

Based on my understanding, it seems challenging to achieve the desired effect using these frameworks.

So, my question is: How can I achieve the desired effect and modify the column definition in Bootstrap or Ink so that each column represents a screen (or a set of columns adding up to 12)? Is this even feasible? Are there any other alternatives I should consider?

Regards, Celso Santos

Answer โ„–1

I didn't test this method myself, but it could potentially solve the issue using pure CSS3 without relying on external libraries.

To implement this approach, start by creating an HTML structure as shown below:

<div id="wrapper">
  <header>Website header</header>
  <section>
    <header>Page header</header>
    <div class="main">
    </div>
  </section>
  <section>
    <header>Page header</header>
    <div class="main">
    </div>
  </section>
  <section>
    <header>Page header</header>
    <div class="main">
    </div>
  </section>
</div>

Next, use CSS table and table-cell properties to achieve the desired column effects. Ensure that the table has a width of 100 multiplied by the number of children elements.

html, body { height: 100%; }
#wrapper { display: table; width: 400%; margin-top: 100px; }
#wrapper > header { position: fixed; top: 0px; height: 100px; width: 100%; } 
#wrapper > section { display: table-cell; height: 100%; width: 25%; }

An additional benefit is that when the screen orientation changes, the page will smoothly rotate and scale accordingly.

UPDATE: Incorporating margins for each section

<div id="wrapper">
  <header>Website header</header>
  <section>
    <div class="page_wrapper">
      <div class="page_bubble">
        <header>Page header</header>
        <div class="main">
        </div>
      </div>
    </div>
  </section>
  <section>
    <div class="page_wrapper">
      <div class="page_bubble">
        <header>Page header</header>
        <div class="main">
        </div>
      </div>
    </div>
  </section>
  <section>
    <div class="page_wrapper">
      <div class="page_bubble">
        <header>Page header</header>
        <div class="main">
        </div>
      </div>
    </div>
  </section>
</div>

Each HTML section now includes a wrapper and a 'bubble' element. Set the wrapper to position: relative, and the bubble container to position: absolute like so:

.page_wrapper { position: relative; width: 100%; height: 100%; } 
.page_bubble { position: absolute; top: 0px; right: 25px; bottom: 0px; left: 25px; }

By applying absolute positioning with defined sides within a wrapper of specified dimensions, it acts as a stretched container filling the relative wrapper with a margin of 25px on both sides while allowing overflow auto if the content exceeds the dimensions :) For more insight into this CSS technique, check out this resource:

SuperStretching elements

Answer โ„–2

Expanding on the previous response and addressing the question of "how to incorporate margin in table-cell structures like the code above?"

While table-cells do not support margins, you can utilize containers for this purpose. In my approach, I distinguish between wrappers and containers. A wrapper envelops its content like a candy bar wrapper, while a container takes up space similar to a sea container on a ship. The container extends beyond the ship's border, following naming conventions. Here's how you can achieve it:

Below is an enhanced version of the initial example:

<div id="wrapper">
  <header>Website header</header>
  <div class="cell">
    <section>
      <div class="container">
        <header>Home header</header>
        <div class="main">
          <p>Testpage hahaha</p>
        </div>
      </div>
    </section>
  </div>
  [additional cell elements]
</div>

html, body, #wrapper { height: 100%; }
#wrapper { display: table; width: 400%; margin-top: 100px; }
[CSS styling rules provided in the original text]

<p>The next rule involves a CSS hack that stretches the element to 100% height and width. All five rules (position absolute, top, left, right, bottom) must be set. By setting left and right to 15px, the .container extends slightly beyond the boundary. Moreover, overflow-y can be used within the containers, enabling scrollbar functionality.</p>

<pre><code>#wrapper > .cell > section > .container { 
  position: absolute; 
  top: 0px; right: 15px; bottom: 0px; left: 15px; 
  overflow-y: auto; border: 1px solid #000000; 
} 

This technique may not seem magical, but it effectively achieves the desired outcome. By utilizing strict naming conventions and '>' selectors, you can implement this approach in various fluid website designs without affecting other elements.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The CSS property input::-webkit-outer-spin-button adjusts the margin-left and is exclusively visible in Chrome browser

Strange things are happening... Let me share the code for my inputs: #sign_in input#submit { height: 56px; background-color: #88b805; font-weight: bold; text-decoration: none; padding: 5px 40px 5px 40px; /* top, right, bottom, left ...

Adjust the size of the images in the Bootstrap navbar brand to make them resizable and move them

After some online research, I discovered a method to create a two-row Bootstrap navbar with the navbar-brand on its own row: <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBn ...

Is the overlap of viewport unit VW less than 100 vw per viewport?

So if I am correct, 1vw represents 1/100th of the width of a viewport, meaning there are 100vw across any given viewport. But here's an interesting scenario - when I have two divs each with a width of 25vw, one positioned 25vw from the right edge and ...

Sometimes, CSS unicode characters may not render correctly and appear as jumbled symbols like "âโ€“¾"

https://i.sstatic.net/eGvzJ.jpg Every now and then, about 1 in every 100 page refreshes, the unicode characters on my page turn into jumbled nonsense (you might need to zoom in to see it clearly). Specifically, the unicode characters are displayed as รข ...

Tips for customizing the mx-fluity navbar code to create multi-tiered dropdown menus

I have limited experience in web design and struggle with understanding CSS code. Can anyone provide guidance on how to create a (multi-level) menu in the popular mx-fluity blogger template that will display consistently on both PC and mobile browsers? T ...

Ensuring Message Accuracy with Selenium in C# Development

I am a beginner in the world of test automation and I am looking to retrieve the value from a web element labeled "message-success failed", which displays the message "This customer name already exists". Here is what the CSS looks like Even though I atte ...

How can I redirect to a different page when a date is selected using datetimepicker in Rails?

I have integrated the bootstrap3-datetimepicker-rails gem into my Rails application. Once a date is selected by the user, I would like to automatically redirect them to a different web page. For example, after selecting a date, the user should be directe ...

Implementing Bootstrap modal functionality in PHP

I'm attempting to trigger a hidden modal from an HTML file using PHP as part of a verification process. One modal is displayed when a button is clicked, while the other is meant to be called by PHP. Below is my PHP code: $File = include("index2.html ...

Using an image tag within a button element causes functionality issues with JavaScript on Chrome

Can anyone help me figure out why my button with an image isn't toggling a div's class in Chrome? It works fine in Firefox. Here is the codepen link for reference: https://codepen.io/luansergiomattos/pen/zydWyM This is the HTML code: <div cl ...

A guide on incorporating ":host" (or ":host()") with ":has()"

Is there a way to properly use :host (or :host()) with :has() ? For instance, like the following code snippets: :host:has([disabled]) { opacity: 0.75; } or :host(:has([disabled])) { opacity: 0.75; } Unfortunately, the opacity value doesn't seem ...

Enhanced Firefox functionality with support for multiple columns

It has come to my attention that Internet Explorer 9 and older versions do not support multiple columns. However, even with the latest version of Firefox, I am experiencing issues with this website loading correctly. Do you have any insight into what might ...

CSS does not support page breaks

https://i.sstatic.net/Q3LIO.png I implemented the following CSS tag: @media print { .page-break { page-break-inside: avoid; } } However, why is the selection splitting across different pages? ...

Appium for testing the functionality of Android hybrid mobile apps

Exploring the realm of test automation, I decided to tackle a basic Hybrid Mobile Application built on Cordova and running on Android. My weapon of choice? Appium. Drawing inspiration from a helpful tutorial video, I kicked off my journey by downloading an ...

Is it possible to create a dropdown menu that exceeds the width of its parent column?

I currently have a dropdown that contains 3 main "categories," each of which includes multiple checkboxes for search filtering purposes. Here is an example snippet of the code: <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4. ...

What is the method for adjusting a "column" of spans to align with the right side?

I need help with aligning the first "column" of spans to the right using only spans instead of divs. Here is the link to my fiddle: http://jsfiddle.net/f6a01v9a/1/ <h4>How to align first "column" of spans to the right?:</h4> <span style=" ...

Styling: petite vibrant square positioned in the corner of a large container

Can you please take a look at the screenshot from the demo app: box over box image I am trying to create a colorful small square box that will appear in the top left corner, on top of the larger parent square box (including all the contents inside the whi ...

Achieving alignment between a button and input field using Bootstrap CSS

Struggling to align my buttons next to the inputs in my project, particularly due to my inexperience with bootstrap CSS and CSS in general. Could someone please point me in the right direction? Link to the issue Unfortunately, my Search and New buttons a ...

I am unable to determine the origin or background of my sidebar

I am having an issue with styling a sidebar using HTML and CSS. The problem I am facing is with setting the background-color property. Despite my efforts to customize the style, the background remains transparent and shows the color of the page beneath it. ...

Image Appears Oversized on Mobile Due to Responsiveness

Attempting to make this landing page responsive has been quite challenging. Unfortunately, on mobile devices the image extends beyond the width of the screen when in portrait mode, requiring users to scroll to view the images and form. My expertise lies in ...

Troubles with Bootstrap's navbar dropdown menu functionality

I seem to be encountering a problem with the dropdown list in my navigation bar. It was functioning correctly yesterday, but something seems to have gone awry as Bootstrap is no longer working for the dropdowns only. I'm puzzled as to why this sudden ...