Positioning Images in Tailwind Modals

I'm currently working on building a modal using Tailwind in Vue, but I've run into some challenges with aligning the elements inside the modal as desired.

I've experimented with removing certain Tailwind classes and have tried implementing grids, flexbox, and other positioning techniques, but the images still appear aligned to the left.

My goal is to have the image centered with some text below it, followed by two additional boxes containing links beneath that. Any suggestions on how to achieve this layout?

Below is the snippet of my code:

<template>
  <div id="app">
    <div class="flex items-center">
      <vue-tailwind-modal
        class="bg-grey-lighter border-b-2 border-grey ml-2 hover:bg-grey-lightest text-grey-darkest font-bold py-4 px-6 rounded "
        :showing="modal"
        @close="modal = false"
      >
        <img class="h-32 w-32 object-center" src="./assets/discord.png" />
        <div
          v-for="item in links"
          :key="item.link"
          class="relative p-8 bg-white w-full max-w-md m-auto flex-col"
        >
          <div>{{ item.name }}</div>
          <div>{{ item.link }}</div>
        </div>
      </vue-tailwind-modal>
      <button @click="toggleModal">Toggle</button>
    </div>
  </div>
</template>

<script>
//import PopUp from "./components/PopUp.vue";
import VueTailwindModal from "vue-tailwind-modal";

export default {
  name: "App",
  components: {
    VueTailwindModal,
    //PopUp,
  },
  data: () => ({
    modal: true,
    links: [
      {
        name: "Google",
        link: "google.com",
      },
      {
        name: "Bing",
        link: "bing.com",
      },
    ],
  }),
  methods: {
    toggleModal() {
      this.modal = !this.modal;
    },
  },
};
</script>

<style></style>

Answer №1

Here's a suggestion for you to try:

<template>
  <div id="app">
    <div class="flex items-center">
   <vue-tailwind-modal class="flex justify-center items-center bg-grey-lighter border-b-2 border-grey ml-2 hover:bg-grey-lightest text-grey-darkest font-bold py-4 px-6 rounded " :showing="modal" @close="modal = false">
    <div class="flex flex-col items-center">
      <img class="h-32 w-32 object-center" src="https://images.pexels.com/photos/5658572/pexels-photo-5658572.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500" />
      <div v-for="(item,i) in links" :key="i" class="p-8">
        <p>{{ item.name }}</p>
        <p>{{ item.link }}</p>
      </div>
    </div>
  </vue-tailwind-modal>

      <button @click="toggleModal">Toggle</button>
    </div>
  </div>
</template>

Incorporate the use of flex display within a parent div, ensuring everything is centered accordingly.

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

Fixing the mobile display issue with react-responsive-carousel

I am relatively new to ReactJS and I am looking to develop a responsive Carousel. Here is the code snippet that I have currently: To achieve a responsive Carousel for both desktop and mobile devices, I utilized the react-responsive-carousel library. The ...

Is there a way to locate a specific word within a sentence using JavaScript

I have these lists of answers: For example: const answerList = [{index: 2, answer: nice}, {index: 5, answer: sunday} ...] similar to that Also, I have a sentence: For instance: "hi i'm theo nice to meet you. how are you" My goal is to identify ...

adjust the dimensions of the clickable icon's background

Is there a way to expand the pressable area of a close icon without altering its size? For example, if the icon is 19X19 pixels, can the pressable area be increased to 39X39 pixels? The concern lies with the div element containing the close button and the ...

Utilize the MaterialUI DataGrid to showcase nested object values in a visually appealing

Hey there, fellow coders! I'm currently working on fetching data from an API and displaying it in a data grid using React.js. Here's the format of the data I'm receiving from the API: {data: Array(200)} data : (200) [{…}, {…}, {…}, { ...

Assign a property to an array of objects depending on the presence of a value in a separate array

Looking to manipulate arrays? Here's a task for you: const arrayToCheck = ['a', 'b', 'c', 'd']; We have the main array as follows: const mainArray = [ {name:'alex', code: 'c'}, ...

Having trouble with Nativescript Vue Developer Tools?

Currently, I am following the tutorial exactly as described here: The development tools are installed and the application is running smoothly on my android emulator. However, I encounter a message in the dev tools that says "Waiting for connection..." des ...

What are the steps to add SVG effects to an image or div element?

Embarking on my first venture into using SVG graphics has left me feeling a bit bewildered. Despite extensive research, I have yet to stumble upon the answer to my current quandary. The objective at hand is to transform an image, assuming that the source ...

Is it advisable to opt for window.webkitRequestAnimationFrame over setInterval?

Trying to figure out the best method for moving game characters in my JavaScript game - should I go with window.webkitRequestAnimationFrame or stick with setInterval? Any advice is appreciated! ...

JavaScript - Issue with retrieving object properties accurately

Here is a code snippet that I am working with: function retrieveObjects(name, data) { return data.filter(function(d) { return name.title == d.title; }).map(function(d) { return { "title": d.title, "sort": d. ...

React Native - Scaling images dynamically

I have a responsive photo grid built within a mobile app. I want to display three images across the screen with equal spacing between them. All the images are squares. Unfortunately, using percentages for each image's width and height is not possible ...

Is there a way to efficiently parse HTML data returned as JSON in the browser using Cordova/Ionic?

Currently, I am retrieving data from a Drupal service and using AngularJS along with the ionic framework to create a hybrid app for mobile platforms, leveraging Cordova or Phonegap. You can check out my code on codepen: http://codepen.io/BruceWhealtonSWE/p ...

Can the data retrieved from a jsonp call that may be considered "bad" be utilized effectively?

When making a JSONP call to another domain, I am receiving data that is in JSON format but not wrapped in a function. This causes a parse error to occur. However, the data is still retrievable and visible. Despite the error, is it possible to utilize the ...

The information provided has been cut off: 1406 The content exceeds the permitted length for the 'image' column in row 1

Whenever I select a random image, the name turns out to be very long despite being a varchar data type. Here is my migration file: $table->id(); $table->string('image'); $table->timestamps(); This code snippet shows my image ...

Is it safe to set content type as text/plain instead of application/json for JSON response?

I've been developing a PHP script to retrieve public JSON data, which will be accessed by JavaScript on the client side. However, I've encountered an issue with the server (LiteSpeed shared hosting) not having brotli/gzip compression enabled for ...

Internet Explorer reverts back to default fonts once the webpage has completed loading

I'm encountering a minor problem with a website I'm currently working on. My CSS and web fonts are from Fonts.com, and everything seems fine except in Internet Explorer. Initially, the page displays with the fonts correctly applied, but once the ...

Exploring the scope of event listeners in jQuery's TimeCircles

Currently experimenting with the jquery timer known as "TimeCircles", which can be found here. I have successfully set up a minute / second timer for 30 minutes with an alert that triggers at 25 minutes. My goal is to implement an event when the timer hits ...

Headers have already been sent to the client and cannot be reset

Although I am relatively new to using nodeJs, I have conducted research to troubleshoot my issue. However, it appears that I am struggling a bit with asynchronous functionalities. I came across a solution that unfortunately did not work as expected. Here i ...

Guide on how to incorporate an external homepage into a quasar/cordova/vue.js mobile application

I have a mobile application built with quasar/cordova/vue.js that I am working on. I want to incorporate a feature where users can browse through an online catalog. Currently, I am using the inappbrowser plugin, which opens the website in full screen mode ...

What is the best way to supply arguments to a generic handler function?

How can I send parameters to a generic handler in Asp.net using JavaScript/jQuery? I am working on a jQuery plugin called ajaxfileupload that utilizes a generic Handler. I need to pass certain arguments from the page using jQuery or JavaScript, such as Dy ...

The function cannot be accessed during the unit test

I have just created a new project in VueJS and incorporated TypeScript into it. Below is my component along with some testing methods: <template> <div></div> </template> <script lang="ts"> import { Component, Vue } from ...