What is the best method for showcasing two images side by side in a column layout?

I need to showcase 2 images in a row using AngularJS, with the next two images in the following row and so forth.

Img1 Img2
Img3 Img4

This is my code:

<section id="content">
<div class="content-wrap">
    <div class="container clearfix ">
        <div id="posts" class="small-thumbs topmargin-sm">
            <div data-ng-repeat="partner in adminPartnersList">
                <span class="col-sm-6 col-md-6" data-ng-if='percent($index) == 0'>
                    <img img-cache class="image_fade mgnbtm" data-ng-src="uploads/{{partner.image}}" onError="this.src='images/noimage.png';" alt="">
                        <ul class="entry-meta clearfix">
                            <li><a ui-sref="edit-partners({'partnerId':partner.partner_id})"><i class="edit-faq-icon icon-edit"></i></a></li>
                            <li><a href="#" data-ng-click="deletePartner(partner._id, $index)"><i class="delete-faq-icon icon-trash2"></i></a></li>
                        </ul>
                </span>
                <span class="col-sm-6 col-md-6" data-ng-if='percent($index) == 1'>
                    <img img-cache class="image_fade mgnbtm" ng-src="uploads/{{partner.image}}" onError="this.src='images/noimage.png';" alt=" ">
                        <ul class="entry-meta clearfix">
                            <li><a ui-sref="edit-partners({'partnerId':partner.partner_id})"><i class="edit-faq-icon icon-edit"></i></a></li>
                            <li><a href="#" data-ng-click="deletePartner(partner._id, $index)"><i class="delete-faq-icon icon-trash2"></i></a></li>
                        </ul>
                </span>
            </div>
        </div>   
    </div>  
    <span class="col-xs-12 text-center text-danger" data-ng-show="isShowNoPartnersMsg">
        No partners were found.
    </span>
    <span ng-show="!isShowNoPartnersMsg" class="col-xs-12 text-center">
        <pagination total-items="totalItems" data-ng-model="currentPage" max-size="maxSize" items-per-page="itemsPerPage" class="pagination-sm" boundary-links="true" data-ng-change="onAdminPartnerPageChanged()"></pagination>
    </span> 
</div>

I am dynamically displaying data and would appreciate any assistance. Thank you.

Answer №1

Here is a suggested solution:

var app = angular.module("myApp", []);
app.controller("myCtrl", function($scope) {
  $scope.test = ["image1", "image2", "image3", "image4", "image5", "image6", "image7", "image8", "image9", "image10"]
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="myApp" ng-controller="myCtrl">
  <section id="content">
    <div class="content-wrap">
      <div class="container clearfix">
        <div id="posts" class="small-thumbs topmargin-sm">
          <div class="entry clearfix" data-ng-repeat="t in test">
            <div ng-if="($index + 1)%2==0" style="border-bottom:1px solid red;padding:5px">
              <img img-cache class="image_fade mgnbtm" data-ng-src="uploads/{{test[$index]}}" alt="{{$index}}" style="border-right:1px solid red;padding-right:5px;" >
              <img img-cache class="image_fade mgnbtm" data-ng-src="uploads/{{test[$index+1]}}" alt="{{$index + 1}}">
            </div>
          </div>
        </div>
      </div>
      <span ng-show="!isShowNoPartnersMsg" class="col-xs-12 text-center"> 
        </span>
    </div>
  </section>
</div>

Answer №2

check out the div with class="col-sm-12"

 <section id="content">
<div class="content-wrap">
    <div class="container clearfix">
        <div id="posts" class="small-thumbs topmargin-sm">
            <div class="entry clearfix" data-ng-repeat="partner in adminPartnersList">
              <div class="col-sm-12">
                <div class="col-sm-6" data-ng-if="percent($index) == 0">
                    <img img-cache class="image_fade mgnbtm" data-ng-src="uploads/{{partner.image}}" onError="this.src='images/noimage.png';" alt="">
                </div>
                <div class="col-sm-6" data-ng-if="percent($index) == 1">
                    <img img-cache class="image_fade mgnbtm" ng-src="uploads/{{partner.image}}" onError="this.src='images/noimage.png';" alt=" ">
                </div>
            </div>
            </div>
        </div>
    </div>  
    <span ng-show="!isShowNoPartnersMsg" class="col-xs-12 text-center">
        <pagination total-items="totalItems" data-ng-model="currentPage"  max-size="maxSize" items-per-page="itemsPerPage" class="pagination-sm" boundary-links="true" data-ng-change="onAdminPartnerPageChanged()"></pagination>
    </span> 
 </div>
</section>

Answer №3

Remember to use col-sm for small screens and col-md for medium screens. Ensure that the img src attribute is only used once.

<div class="entry clearfix row" data-ng-repeat="partner in adminPartnersList">
     <div class="col-sm-6 col-md-6" data-ng-if="percent($index) == 0">
          <img img-cache class="image_fade mgnbtm" data-ng-src="uploads/{{partner.image}}" onError="this.src='images/noimage.png';" alt="" />
     </div>
</div>

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 is the best way to title an uploaded chunk with HTML5?

Here is the script I am working with: function upload_by_chunks() { var chunk_size = 1048576; // 1MB function slice(start, end) { if (file.slice) { return file.slice(start, end); } else if (file.webkitSlice) { ...

Tips for utilizing JavaScript getElementByClassName to retrieve all the elements within a ul without having to specify the class name in each li

Looking to tidy up my HTML/CSS. Is there a way to keep this JavaScript functioning without needing to add the class name to every li element within the ul? Any suggestions on how to improve the visual appeal and readability of the HTML code? const Profi ...

Interacting with blog posts through comments on both Facebook and the blog's official page on the social media

I'm currently working on a PHP blog and I am looking to integrate Facebook comments into each blog post. My goal is for these comments to be visible both on the website and on its corresponding Facebook page, allowing users from different platforms to ...

Is there a way to modify the color scheme of my webpage while utilizing Bootstrap?

As I delve into programming with Bootstrap, I encountered an issue while attempting to change the background color of my body. Even though I used the following CSS code: body { background-color: #eba; width: 100%; height: 100%; } The color change ...

Storing a MySQL query result in a global array in a Node.js environment

Just diving into the world of Node.js and Express, I'm trying to wrap my head around asynchronous functions and global variables. Specifically, I'm working on connecting to a MySQL database, fetching query results, and displaying them on a test.h ...

HTML header with zero margin

Hi there! I am currently learning the basics of HTML and CSS. I have a question regarding creating a header with no margins on the edges. Any advice would be greatly appreciated as I haven't been able to find a clear solution. Below is my code snippet ...

Accessing a Complex Type Constructor in Web API 2

I am currently exploring the world of Web API and attempting to incorporate it into a project I am actively involved in. One issue I am encountering is when I try to send a complex type to a WebApi action; it triggers my type constructor, which in turn re ...

AngularJS object array function parameter is not defined

Recently, I've been honing my AngularJS1x skills by following tutorials on Lynda and Udemy. One tutorial involved creating a multiple choice quiz. To test my understanding, I decided to modify the code and transform it into a fill-in-the-blank quiz. ...

Rotation of Weekly Menus

I have a project to enhance our Menu Order Website by adding a weekly rotating menu feature. I have completed the entire website, including the admin panels, but I am struggling to implement the rotating menu functionality. Currently, all menus are include ...

The alignment is off

<script> var myVar = setInterval(myTimer, 1000); function myTimer() { var d = new Date(); document.getElementById("demo").innerHTML = d.toLocaleTimeString(); } </script> <p text-align="right" id="demo" style="font-family:Comic Sans ...

The appearance of my sidebar items' right border varies depending on the web browser being used

My sidebar item's right border appears differently in Mozilla and Chrome. How can I resolve this issue? Here are the images from both browsers: https://i.stack.imgur.com/YGkkz.png https://i.stack.imgur.com/JxNs3.png "use client"; import { ...

What is the best way to modify the underline style of a tab in Material UI?

I'm trying to customize the underline of: https://i.stack.imgur.com/J2R1z.png Currently, I am using material ui version 4.12.3 The code snippet for generating my tabs is below: function renderTabs(): JSX.Element { return ( <Tabs className={cla ...

JavaScript prototype error: caught TypeError - attempting to call undefined function

I am facing challenges while attempting to create a Factory in AngularJS. I have moved the code from the controller to the factory and made a few adjustments for it to function properly. Here is the error that I am encountering: "El objeto no acepta la p ...

What is the best method for extracting [object Text] using XPath?

I'm currently working with Selenium and attempting to extract text from a node that contains the keyword "approved," but I'm unsure of how to retrieve and validate this specific text. Here is the node structure - <div class="Notification-bo ...

Dynamic content can be embedded into AngularJS Bootstrap-ui tabs

To showcase my app, I have created a Plunker available at the following link: http://plnkr.co/edit/iIJVuIxspDRedN7ZXiTK?p=preview <tabset> <tab ng-repeat="tab in tabs" heading="{{tab.title}}" select="getContent()" active="tab.active" disabled= ...

Use JavaScript to enclose elements that are siblings within a DIV

Can you help me convert the elements with class "a" into a div using JavaScript, while maintaining their order within their sibling elements? I've been struggling with the code below and would appreciate any assistance. const elementParent= documen ...

Having trouble configuring Angular-UI Router to work properly with Apache server

My web app is running on my PC through an Apache server, but I'm having issues with the routing provided by ui.route. It seems that the simple state I defined is never being reached. To troubleshoot, I added a wildcard to catch all paths and found th ...

An error occurred stating: "The require function is not defined in AngularJS and nodeJS."

I have searched through various similar questions here on SO, but none seem to provide a solution that fits my specific case. I am relatively new to using angularjs and nodejs, and I am encountering an issue that has me stuck. My goal is to save the input ...

What is the best way to showcase AJAX data within a complex HTML structure?

I need assistance with displaying the JSON output in my HTML code. My current HTML code is quite complex, so I am unsure how to include this data and repeat the HTML section for every JSON element. Can you provide guidance on how to achieve this? HTML COD ...

AngularJS: Starting a $scope property in the right way

Check out my small angular code snippet below: html file: <body ng-controller="myCtrl"> <div class="container"> .... </div> </body> javascript file: app.controller('myCtrl', function($scope) { $scope.wh ...