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

Issue with ReactJS: onChange event does not function properly when value is changed using jQuery

This is the reactjs code I am working with: <input name="date" id="date" value={this.state.listManage.date} onChange={this.handleForm} type="text" /> When I manually type in the input field, the onChange function works ...

To style the input box, apply the CSS properties "filter: alpha(opacity=70);" and "background-image: url(image.png);"

Individual functionality for both the form and css has been achieved, but when trying to implement them together, they do not work as intended. This integration is specifically for a windows sidebar gadget. Here is the structure of the form: <form nam ...

To generate a new <div> element by clicking a button and then clicking on it using C# Selenium

Before clicking the button, this is the initial HTML code for the page: <div id="layerContainer"> </div> After clicking the button, the code changes as shown in the picture here I have been attempting to locate the new button, but I keep rec ...

Unable to retrieve property from Vuex store object

Firstly, I start up my store using the JSON file named config.json: { "branding": { "button": { "secondary": { "background_color": "#EC6B24", ... }, ... } } } ...

What is the process for configuring my CSS and JS files to send HTTP response headers?

During our security evaluation of a web application built in Laravel 4, we discovered that the Anti-MIME-Sniffing header X-Content-Type-Options was not properly configured to 'nosniff'. The following PHP code snippet sets the necessary HTTP heade ...

How can I efficiently make multiple API calls using redux-thunk?

This is the approach I took. const redux = require('redux') const thunkMiddleware = require('redux-thunk').default const axios = require('axios') const reduxLogger = require('redux-logger') const createStore = redu ...

The AJAX request encountered an unexpected failure that cannot be identified (Using jQuery)

Are you facing issues with a service that returns JSON data? Check out this URL: If you're attempting a simple AJAX request, here's some sample code to get you started: $.ajax({ type: "get", url: "http://api.drag2droid.shamanland.com/ca ...

Schema-based validation by Joi is recommended for this scenario

How can we apply Joi validation to the schema shown below? What is the process for validating nested objects and arrays in this context? const user = { address: { contactName: 'Sunny', detailAddress: { line1: & ...

script code to limit selection of dates within a predefined range

I'm seeking assistance to limit my customers from selecting a date beyond 10 days in advance. Although I previously had a code that functioned properly when there were more than 10 days left in the current month, it is now ineffective. This is becaus ...

If the user confirms it with a bootstrap dialog box, they will be redirected to the corresponding links

Firstly, I am not interested in using javascript confirm for this purpose. Please read on. For example, adding an onClick attribute to each link with a function that triggers a system dialog box is not what I want. Instead of the standard system dialog bo ...

What is the best way to add animation to my `<div>` elements when my website is first loaded?

I am looking for a way to enhance the appearance of my <div> contents when my website loads. They should gradually appear one after the other as the website loads. Additionally, the background image should load slowly due to being filtered by the wea ...

What is the best way to connect a nested Vuex object to a Vue.js property within the Tiptap text editor?

I'm attempting to connect the nested Vuex state object to the editor property of the tiptap's editor-content component. The structure of the state is as follows: <template> <table :style="{ backgroundColor: element.options.ba ...

Extract data from the HTML source code in JavaScript and transfer it to a personalized JavaScript variable within Google Tag Manager

Running an e-commerce website on Prestashop and facing an issue with data layer set up. Instead of a standard data layer, the platform generates a javascript variable called MBG for Enhanced E-Commerce implementation. <script type="text/javascript"> ...

Configuration options for content division in a table cell

Please see the following fiddle which I have attempted: http://jsfiddle.net/9LdEc/ code: html: <div id="CorpDealerSearch"> <div class="row"> <div class="left"> Quarter To Date </div&g ...

What could be preventing my XPath from selecting a link/button using its label text?

<a href="javascript:void(0)" title="home"> <span class="menu_icon">Possibly more content could go here</span> Home </a> When I use //a as the XPath in the above code, it is highlighted. However, when I try //a[contains(text ...

Issue with nested promises not functioning as anticipated within a for loop

I'm currently facing an issue with extending a Promise inside a .then() block. My goal is to update records in the database using a for-loop and then close the database after all updates have been processed. However, the application is exiting abruptl ...

How can I update the input value for each object in an array using v-for in Vue?

I am creating a shopping cart feature and I want to display the price of each product based on its quantity. The issue I'm facing is that when I adjust the quantity for one product, it changes for all products because they share the same data. How can ...

Troubleshooting a problem with the Jquery cycle plugin in HTML and CSS

Hi there! I've successfully integrated the jQuery cycle plugin into my slideshow, which is working great. However, I want to make the navigation controls (previous, next, pause, play) display as background images instead of visible text links. I' ...

Tips for dynamically updating the id value while iterating through a class

Here's the HTML snippet I am working with: <div class="info"> <div class="form-group"> <label class="control-label col-sm-2">Title</label> <div class="col-xs-10 col-sm-8"> <inpu ...

Sharing data between VueJS2 components

I am working on a project where the parent component retrieves a large JSON object from the server. My goal is to parse this data and then pass it down to the child components. The structure of the child components is as follows: <child-comp /> I ...