Creative ways to use images as borders with CSS in React JS

import React, { Component } from 'react';

class BigText extends Component {

  constructor(props) {
        super(props);

        this.state = {
            title: '',
            text: '',
            summary: ''
        };

        this.handleInputChange = this.handleInputChange.bind(this);
    }

    handleInputChange(event) {

        this.setState({
            [event.target.name]: event.target.value
        });

    }

  render() {
 
    return ( 
      <div>
        <div>
          <h1 className="row px-2">Big Text Notification</h1>
          <hr />
          <div className="row px-1 py-2 animated fadeIn">
  
                <div className="px-1" style={{ width:50 + '%' }}><br />

                    <div className="mb-1">
                      <input type="text"
                       className="form-control" 
                       placeholder="Title"
                       name="title"
                       value={this.state.title}
                       onChange={this.handleInputChange}
                       />
                    </div>

                    <div className="mb-1">
                      <textarea 
                      className="form-control" 
                      placeholder="Text"
                      name="text"
                      value={this.state.text}
                      onChange={this.handleInputChange}
                      />
                    </div>

                    <div className="mb-1">
                      <textarea
                       className="form-control" 
                       placeholder="Summary"
                       name="summary"
                       value={this.state.summary}
                       onChange={this.handleInputChange}
                       />
                    </div>

                    <br />

                    <div className="row px-2" >
                      <div>
                        <button className="nav-link btn btn-block btn-info">Save</button>
                      </div>
                      <div className="px-1">
                        <button className="nav-link btn btn-block btn-danger"> Cancel</button>
                      </div>
                    </div><br />

                </div>
                <div><br />
                  <div className="px-1">
                    <table className="table table-clear table-hover table-striped"
                    >
                      <tbody>
                        <tr>
                          <td>
                            <strong>
                              {this.state.title}
                            </strong><br />
                            {this.state.text}  <br />{this.state.summary}<br /> 
                          </td>
                        </tr>
                      </tbody>
                    </table>
                  </div>
                </div>
          </div>
    </div>
    </div>
    )
    
  }
}

export default BigText;

I plan to create a custom CSS design that wraps the input fields in a border resembling a smartphone image. This will be used in conjunction with a React JS application where the user's typed input is displayed within the styled phone component on the right side. Follow this link for the image I intend to use as the border: Smartphone Border Image

Answer №1

.unique-style {
  min-width: 410px;
  max-width: 450px;
  border-style: solid;
border-width: 45px 103px 267px 98px;
-moz-border-image: url(https://d3nj7353mvgauu.cloudfront.net/media/categories/iphone-77-plus-40-b1ac.png) 45 103 267 98 stretch repeat;
-webkit-border-image: url(https://d3nj7353mvgauu.cloudfront.net/media/categories/iphone-77-plus-40-b1ac.png) 45 103 267 98 stretch repeat;
-o-border-image: url(https://d3nj7353mvgauu.cloudfront.net/media/categories/iphone-77-plus-40-b1ac.png) 45 103 267 98 stretch repeat;
border-image: url(https://d3nj7353mvgauu.cloudfront.net/media/categories/iphone-77-plus-40-b1ac.png) 45 103 267 98 stretch repeat;
}

.customized-width {
  min-width: 210px;
  max-width: 250px;
    word-break: break-all;
}

This is my successful implementation of the desired action.

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

Unable to commit changes to a fresh Github repository

After successfully pushing my code to a repository on GitHub, I encountered difficulties when attempting to push my 'backend' folder. Despite eventually managing to do so, the code did not look the same as it did in VS Code. In an effort to maint ...

What steps should I take to incorporate a timer into my bot similar to the timer used by other giveaway bots

I am looking to add a timer to my bot giveaway embed message that continues to update itself even when the bot is offline, without showing that the message was edited. Here's what I currently have in my embed: const embed = new MessageEmbed(); ...

Is there a way to customize the color of specific sections on a dygraph chart?

I am looking to incorporate dygraphs into my website, but I need help with displaying a specific background color in certain parts of the chart. For example, I want the chart to show green during daylight hours. Can you assist me in achieving this? ...

Tips for Choosing Certain List Items in a Responsive Bootstrap Navigation Menu for WordPress

I've put together a sleek bootstrap navbar menu for WordPress. If you want to check out the menu design, you can view it by clicking on this link: here There are still some tweaks that need to be made though. Specifically, I need to add a box around ...

What is the best way to eliminate the # symbol from a URL within a Vue.js application when utilizing a CDN

When constructing a vue.js application using CLI and vue-router, you can include mode: 'history' in the router to remove the hash from the URL. However, is there a way to eliminate the # from the URL when using Vue through a CDN? For instance, in ...

Using PHP variables in JavaScript fetched through AJAX loading

I am currently attempting to retrieve a PHP variable from another page using AJAX in JavaScript, but it is not displaying any alerts. This is the PHP code for 'getposY': <?php include"connectdatabase.php"; $posYquery=mysql_query("Select posY ...

Show on smartphones, conceal on desktops - Activation/URL

I'm attempting to create a click-to-call link on my website using the following: <a class="mobile-only" href="tel:+534306464456"><p class="">Click Here to call us</p></a> I want this link to only show up on mobile devices, sp ...

Playfully imitating cross-fetch

I am currently running tests on a Next/React project using Jest with Node. I have also implemented cross-fetch in my project. However, I encountered an issue when trying to mock cross-fetch for a specific component: import crossFetch from 'cross-fetc ...

Incorporate a notification into the Windows notification center without it being visibly displayed on the desktop

I am currently developing an Electron application that includes a custom Notification feature. This feature involves html5 divs appearing and disappearing as necessary on a frameless, transparent, always-on-top window. Although the feature works well, I s ...

What is causing my HTML file path to function on my server, but not when I access the HTML file directly?

My file structure is organized as follows: The main file is located in the folder "HTML-Project/index.html". Within this folder, I have my style.css file and two other folders: one for pictures (HTML-Project/pictures) and another for categories (HTML-Proje ...

Tips for reducing unnecessary re-renders using React Hooks, function components, and optimizing functions based on a list of items

List of items to display Provided a list of items fetched from the server: const itemsFetched = { "1": { id: "1", value: "test" }, "2": { id: "2", value: "another row" } } ...

Issue with MUI Data Grid sorting: Data Grid sortComparator function returning undefined

I'm attempting to organize data with nested values in a data grid, but I keep receiving 'undefined' on the sortComparator of Data Grid Columns. Code: Column Data Setup: { headerName: 'Title', field: `${this.props.type} ...

What are the steps to create custom Typescript RecursiveOmit and RecursivePick declarations for efficient cloning routines?

For some time now, I have been attempting to create a declaration for RecursiveOmit and RecursivePick in cloning methods such as JSON.parse(JSON.stringify(obj, ['myProperty'])) type RecursiveKey<T> = T extends object ? keyof T | RecursiveKe ...

Tips for implementing SVG in background images on Internet Explorer

Having a similar issue to the one discussed in this thread. My background images are functioning properly on all browsers except for versions lower than IE10. After reading through that post, I created a background image in SVG format specifically for IE10 ...

Next.js continues to redirect with two locales repeatedly

I am currently working on implementing a client redirection logic based on the client's desired locale in the page. Here is what I added: redirect: !isPossibleLang ? { destination: `/${locale}/main/${id}`, statusCode: 301 ...

Tips for aligning a button in the center of an image across different screen sizes using CSS or bootstrap

I currently have a centered button on my hero image, but the issue is that I would need to use multiple media queries to ensure it stays centered on all screen sizes. <style> .hero-container{ position: relative; text-align: center; } .her ...

Google Maps Info Window with Asynchronous Loading

Need help with loading a Google map asynchronously on your website? Check out the code snippet below: function initialize(lat,lng) { var mapProp = { center: new google.maps.LatLng(lat,lng), zoom:15, mapTypeId: google.maps.MapTypeId.R ...

Leveraging the output of the useSelector() hook within a component

Currently, I am utilizing react-redux for state management and axios to handle API requests. Here is my initial state setup: const defaultState = { isLoading: true, isAuthenticated: false, authUser: {} } After a successful login API call, bot ...

Trigger the opening of Material UI accordion based on the location hash

Trying to open a specific Accordion section using location.hash (such as #panel-1). I loop through the categories and display them like this: <Accordion elevation={1} defaultExpanded={false} className="filter-items-accordion" id={key.replace( ...

The function window.addEventListener('load') functions properly on desktop computers, but does not work on mobile devices

After developing a react website, I noticed that it functions correctly on PC but not on Mobile devices. componentDidMount() { window.addEventListener('scroll', this.onScroll); // This event works fine window.addEventListener('load&a ...