Positioning MDL cards in HTML documents

Seeking guidance on positioning MDL cards alongside existing text. I've attempted various methods without success so far, and the desired outcome has not been achieved.

The goal is to have text aligned to the left (which is currently satisfactory) with two wide MDL cards stacked vertically on the right, in line with the text.

Current code snippets:

<body>
    <div class="header">

            <a class="logo" target="_blank"><img src=".\images\logo.png" border="0" alt="logo" width="90"></a>
            <div class="header-left">
              <a href="index.html">Home</a>
              <a href="wall.html">Wall</a>
              <a class="active" href="shop.html">Shop</a>
              <a href="blog.html">Blog</a>
              <a href="faq.html">FAQ</a>
        <div class="header-right">
              <a class="active" href="http://instagram.com/woolybox" target="_blank"><img src=".\images\instagram.png" border="0" alt="instagram"img width="20" height="20"></a>
              <a href="http://twitter.com/wooly_box" target="_blank"><img src=".\images\twitter.png" border="0" alt="twitter" img width="20" height="20"></a>
            </div>
            </div>
  <p>
    
<table>
  <div class="boxed-1">
      Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus sed feugiat lectus...
    </div></table>
<p>
  <div class="col">
    <div class="row">
      <div class="float-right">
        <div class="demo-card-wide mdl-card mdl-shadow--2dp">
            // MDL card content
          </div>
        </div>
      </div>
    </div>
  <p>
      <div class="col">
        <div class="row">
          <div class="float-right">
              <div class="demo-card-wide mdl-card mdl-shadow--2dp">
                  // MDL card content
                </div>
              </div>
            </div>
          </div>
    <p>

<footer class="mdl-mega-footer">
  
    <div class="mdl-mega-footer__middle-section">
      // Footer content
    </div>

    <div class="mdl-mega-footer__bottom-section">
      // Footer content
    </div>
  </p></div>

</body>

CSS styles included:

// CSS styles mentioned here

html, body { 
  height: 100%; 
  min-height: 100%; 
}

// Header styles

.header {
    overflow: hidden;
    background-color: #ffffff;
  }

// Additional styling for other elements...

.demo-card-square.mdl-card {
  width: 320px;
  height: 320px;
}

// Responsive design adjustments...

Any assistance or recommendations on where corrections are needed would be greatly appreciated.

Answer №1

If you're aiming to achieve a specific layout, there are multiple methods you can explore. One straightforward approach is utilizing flexbox. Below is an example showcasing a basic Material Design Lite layout featuring a header, main content, and footer with text and card alignment as described.

You'll notice that the main html element is styled with display: flex and align-items: center, which aligns its child elements horizontally and centers them vertically. The cards are enclosed within a div to ensure they appear stacked next to the text (instead of side by side).

.mdl-layout__content main {
  padding: 16px;
  display: flex;
  align-items: center;
}

.mdl-card {
  margin: 8px;
}
<!DOCTYPE html>
<html lang="en">

  <head>
    <meta charset="utf-8>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Material Design Lite layout example</title>
    <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
    <link rel="stylesheet" href="https://code.getmdl.io/1.3.0/material.indigo-pink.min.css">
  </head>

  <body>

    <div class="mdl-layout mdl-js-layout mdl-layout--fixed-header">

      <header class="mdl-layout__header">
        <div class="mdl-layout__header-row">
          <span class="mdl-layout-title">Logo</span>
          <div class="mdl-layout-spacer"></div>
          <nav class="mdl-navigation">
            <a class="mdl-navigation__link" href="">Link</a>
            <a class="mdl-navigation__link" href="">Link</a>
            <a class="mdl-navigation__link" href="">Link</a>
            <a class="mdl-navigation__link" href="">Link</a>
          </nav>
        </div>
      </header>

      <div class="mdl-layout__content">

        <main>

          <div class="text">
            Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus sed feugiat lectus. Phasellus maximus, ex nec bibendum volutpat, justo erat pellentesque massa, vel malesuada sem lectus tincidunt orci. Aenean eleifend est sit amet dapibus ullamcorper.
            Nam ornare finibus ex vitae interdum. Sed quis purus eros. Sed ut porttitor dolor, eget ultrices justo. Sed eu leo porta, mattis libero eu, sagittis metus. Vivamus nec lobortis nisi. Suspendisse posuere enim arcu, at interdum dui congue vitae.
            Aliquam vestibulum accumsan magna. Vivamus a arcu nunc. Cras euismod lacinia augue sed elementum. Phasellus dignissim semper mi at sollicitudin. Vivamus maximus semper nulla. Donec luctus, dolor non viverra aliquam, enim arcu imperdiet sem,
            et pretium dui ante ac lectus.
          </div>

          <div class="cards">

            <div class="mdl-card mdl-shadow--2dp">
              <div class="mdl-card__title">
                <h2 class="mdl-card__title-text">Welcome</h2>
              </div>
              <div class="mdl-card__supporting-text">
                Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris sagittis pellentesque lacus eleifend lacinia...
              </div>
              <div class="mdl-card__actions mdl-card--border">
                <a class="mdl-button mdl-button--colored mdl-js-button mdl-js-ripple-effect">
                  Get Started
                </a>
              </div>
              <div class="mdl-card__menu">
                <button class="mdl-button mdl-button--icon mdl-js-button mdl-js-ripple-effect">
                  <i class="material-icons">share</i>
                </button>
              </div>
            </div>

            <div class="mdl-card mdl-shadow--2dp">
              <div class="mdl-card__title">
                <h2 class="mdl-card__title-text">Welcome</h2>
              </div>
              <div class="mdl-card__supporting-text">
                Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris sagittis pellentesque lacus eleifend lacinia...
              </div>
              <div class="mdl-card__actions mdl-card--border">
                <a class="mdl-button mdl-button--colored mdl-js-button mdl-js-ripple-effect">
                  Get Started
                </a>
              </div>
              <div class="mdl-card__menu">
                <button class="mdl-button mdl-button--icon mdl-js-button mdl-js-ripple-effect">
                  <i class="material-icons">share</i>
                </button>
              </div>
            </div>

          </div>
          <!-- close cards -->

        </main>

        <footer class="mdl-mini-footer">
          <div class="mdl-mini-footer__left-section">
            <div class="mdl-logo">Title</div>
            <ul class="mdl-mini-footer__link-list">
              <li><a href="#">Help</a></li>
              <li><a href="#">Privacy & Terms</a></li>
            </ul>
          </div>
        </footer>

      </div>
      <!-- close mdl-layout__content -->

    </div>
    <!-- close mdl-layout -->

    <script src="https://code.getmdl.io/1.3.0/material.min.js"></script>

  </body>

</html>

It appears in your HTML that p tags are being used for line breaks without closing the tag (consider using the appropriate br tag instead, though adjusting margin and/or padding values in your CSS might be more suitable). Additionally, the footer tag was left unclosed. Utilizing an HTML validator can help rectify such syntax errors.

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

What are the best ways to expand image mapping?

It can be a bit challenging, but I'll do my best to explain. I have an image that is sized at 1920 by 1080 pixels and it adjusts based on the window size. The issue arises when the image mapping doesn't adjust accordingly. The coordinates remain ...

Flex wrap is causing additional space within the layout

When using flex-wrap, if there are more textBoxes than the available width in the container, they shift to the next line. This is fine, but it leaves too much space between the button and the textBox. This spacing issue can make the layout look odd. I hav ...

Utilizing NSURL to insert HTML credentials into the <input> tag

Trying to send a request from my iOS app to the Mistar website through NSURLSession. The goal is to load the website in the background, provide username and password strings into the input fields, and gain access to the logged-in page. This is the relevan ...

Tips for adjusting the dimensions of my chart using JavaScript or Jquery

Utilizing DevExtreme widgets for the creation of a line chart in jQuery as shown below: var dataSource = [{"Date Range": "August-2018", Benelux: 194, Czech_Slovakia: 128, ...

Animating a spinning SVG path around its center within a larger rectangular box

Is there a way to rotate a smaller SVG path within a larger rectangle around its own center? The current code rotates the entire space. <animateTransform attributeType="xml" attributeName="transform" type="rotat ...

Hiding content with a fixed Bootstrap menu

How can I prevent the fixed menu in my web page from hiding content, especially when the screen size is reduced and responsive menu hides even more content? Here's an example of the code: <nav class="navbar navbar-inverse navbar-fixed-top" styl ...

Ways to Export HTML to Document without any borders or colorful text

How can I make a contentEditable area visible when filling text and then disappear when exporting the document? I found a script online that allows you to do this, but the issue is that the contentEditable area is not visible until clicked on. To address t ...

The sticky positioning in <table> element fails to function properly in Firefox as well as Chrome version 58

Visit the website Scroll down until you see the "The First 40 Elements" table. Continue scrolling to reach the end of the page. In Chrome version 57, the table header stays sticky, but in Chrome 58 it does not. Interestingly, the table header also does n ...

What is the process for setting up custom HTML tags in Resharper?

I am looking to customize my HTML files by using custom tags to incorporate knockout components [1]: <like-widget params="value: userRating"></like-widget> To enable the tag in VisualStudio's HTML formatting settings, I made the followin ...

"Upon choosing a file using the HTML input file multiple element, a triggered event

After selecting multiple files using the input type="file" HTML element, I am eager to start uploading them. Can you tell me which event I should use to execute code immediately after finalizing my file selection? This is what my HTML code looks like: &l ...

Allowing breaks with the :nth-child() selector

There must be a straightforward explanation for this perplexing issue. However, in my view, it ought to function as intended. We are currently utilizing the Bootstrap 3 CSS framework. The following code is present on a specific page: <div class="promo ...

The functionality of HTML5 canvas image objects is not functioning as expected

I have been working on a function to retrieve an image object using HTML5 canvas, but I keep encountering an error alert (onerror event) function FetchImage() { var img = new Image(); img.src = "http://localhost/assets/images/loadedsprite.png"; ...

Break down and simplify the code into individual components

<input type='button' class="myButton" onclick="document.body.style.cssText+=';background-image: url(img01.jpg);background-repeat: no-repeat; -moz-background-size: cover; -o-background-size: cover; background-size: cover;';" value="S ...

Utilizing jQuery to Adjust Tab Transparency

I'm trying to add some opacity to my jQuery tabs, but so far I've only been successful with accordions. Any tips or tricks for achieving this effect with tabs? Styling with CSS .ui-tabs{ background-image: none; background: rgba(204, 204 ...

Create a layout using jquery-tokeninput

Currently, my project incorporates jQuery-tokenInput and everything is functioning properly. However, I now have the desire to customize the design of the results that are displayed. For example, I want to adjust the width or make any other design changes. ...

What is the best way to personalize Material UI elements, such as getting rid of the blue outline on the Select component?

Embarking on my journey of developing a React app, I made the decision to incorporate Material UI for its array of pre-built components. However, delving into the customization of these components and their styles has proven to be quite challenging for me ...

Tips for transferring an element from different components to a designated component in React.js

In my project, I have a <Header> component and another component called <AboutMe>. My goal is to select an element by its ID from the <AboutMe> component and attach an event listener for onClick. However, whenever I attempt to use getEl ...

Tips on utilizing the identical template in ngIf

I need to display different templates based on certain conditions. For example: <template [ngIf]="item.url.indexOf('http') == -1"> <a class="ripple-effect" [routerLink]="[item.url]" *ngIf="isUserLoggedIn == true" > ...

What are some ways to customize the text and button location for Bootstrap 5's file input?

Bootstrap 5's input type file seems too simplistic. Check it out here https://i.stack.imgur.com/VZ0h5.png I am curious about three things: Can the "Choose file" button be moved to the right? Is it possible to change the message that says "No files ...

Clicking on AngularJS ng-click to navigate to a different page within an Ionic framework application

My goal is to navigate to another page when clicking on a button in the Ionic navbar at the top. However, I am encountering an issue where upon clicking, all nav bar buttons disappear. Interestingly, using dummy codes triggers an alert successfully. But w ...