Can anyone provide pointers on incorporating a corner ribbon to a Material-UI
card? Currently, I am utilizing makeStyles
for styling from Material UI
.
Can anyone provide pointers on incorporating a corner ribbon to a Material-UI
card? Currently, I am utilizing makeStyles
for styling from Material UI
.
You have the option to embellish your Material Ui card with 4 ribbons in the corners (top-left, top-right, bottom-left, and bottom-right).
To achieve this, start by creating a card using Material Ui design.
Next, position the card relative to the parent container and create an inside div with absolute positioning.
Furthermore, you can add CSS pseudo-elements for ribbon borders adjustments as shown in the code snippet below.
import React from 'react';
import { makeStyles } from '@material-ui/core/styles';
import Card from '@material-ui/core/Card';
CardActionArea from '@material-ui/core/CardActionArea';
import CardActions from '@material-ui/core/CardActions';
import CardContent from '@material-ui/core/CardContent';
CardMedia from '@material-ui/core/CardMedia';
import Button from '@material-ui/core/Button';
import Typography from '@material-ui/core/Typography';
root: {
margin: '0 auto',
width: 500,
},
card: {
maxWidth: 360,
marginTop: 40,
position: "relative",
},
ribbon: {
backgroundColor: 'skyblue',
position: "absolute",
color: 'white',
width: 150,
zIndex: 3,
textAlign: 'center',
textTransform: 'uppercase',
padding: 5,
font: 'Lato',
'&::before': {
position: "absolute",
zIndex: -1,
content: '',
display: 'block',
border: '5px solid #2980b9',
},
'&::after': {
position: "absolute",
zIndex: -1,
content: '',
display: 'block',
border: '5px solid #2980b9',
},
transform: 'rotate(-45deg)',
top: 60,
marginLeft: -40,
},
span: {
}
export default function RibbonMaterialCard() {
const classes = useStyles();
return (
<div className={classes.root}>
<div className={classes.ribbon}><span className={classes.span}>ribbon</span>
</div>
<Card className={classes.card}>
<CardActionArea>
<CardMedia
component="img"
alt="Contemplative Reptile"
height="140"
image="/static/images/cards/contemplative-reptile.jpg"
title="Contemplative Reptile"
/>
<CardContent>
<Typography gutterBottom variant="h5" component="h2">
Lizard
</Typography>
<Typography variant="body2" color="textSecondary" component="p">
Lizards are a widespread group of squamate reptiles, with over 6,000
species, ranging
across all continents except Antarctica
</Typography>
</CardContent>
</CardActionArea>
<CardActions>
<Button size="small" color="primary">
Share
</Button>
<Button size="small" color="primary">
Learn More
</Button>
</CardActions>
</Card>
</div>
);
}
I am utilizing the $.ajax function to retrieve content, however I am encountering an issue when attempting to display special tags from it. The data appears to be missing! This is how I am currently handling it: $(document).ready(function(){ $("button") ...
Could someone please assist me in simplifying this code? I am trying to shorten or simplify the query code by using a stored procedure, but I still need to include the details inside the "()" parentheses. I am new to Node.js and would appreciate any help. ...
I'm having trouble getting this block of code to function properly: $("a.expand_all").on("click",function(){ $(this).text('Hide'); $('.answer').each(function () { $(this).slideDown(150, function () { $( ...
I am currently working on customizing the appearance of a JavaScript date counter. My goal is to style the days, hours, minutes, and seconds individually. Ideally, I want each unit to be right-aligned within its own div, with specific left and top absolute ...
I seem to be experiencing a mental block on how to arrange bootstrap cards in a horizontal layout using a for each loop. By default, they appear vertically. Below is my razor code: @foreach (var item in Model) { var imgUrl = Url.Content("~/Conte ...
I've been trying to implement a small animation using componentDidMount and componentWillUnmount, but unfortunately, it doesn't seem to be working as expected. Here's the code snippet I have: import React from 'react' import { Ani ...
Any help or advice would be greatly appreciated. I have configured webpack and everything works in production mode, but the webpack-dev-server is not recognizing static files and is giving the error "Cannot get /". How can I resolve this issue? Thank you i ...
I am interested in creating a unique button component using HTML code like the following: <button class="button_57" role="button"> <span class="text">Button</span> <span>Alternate text</span> ...
Can you help me create a JavaScript array and save another array of data to be part of the newly created array in JavaScript? I attempted it using the code below. Code: var vvv=this.new_products.length-this.quote.lines.length; let mmm={}; if(v ...
I've almost got everything working, but I'm facing a challenge in displaying all 12 sections of the rainbow wheel. I know it's probably something very simple (Occam's razor). I've been following this amazing tutorial on CSS linear ...
Recently, I stumbled upon a technique to prevent page refreshing after submitting a form by using event.preventDefault();. As someone who is still learning Angular, I am unsure of how to incorporate this syntax into my Angular controller. Is "event" some s ...
I'm having trouble retrieving data from a JSONP source, as it keeps throwing a Syntax error when the function is called. I am quite new to this subject and find it hard to understand why this error occurs. It seems like my understanding of JSONP reque ...
Trying to call a method within a directive from transcluded content. The structure of my HTML is: <typeahead class="typeahead" model="customers" filtered-model="customersfiltered" ng-model="selectedcustomer"> <ul> <li ng-click="select ...
As a newcomer to AngularJS, I am facing an issue with redirecting my page to the dashboard once the user has logged in. I receive an access token after login, which I save in cookies. Despite trying solutions from Stack Overflow, I have not been able to re ...
Recently, we made the decision to streamline the installation process of Protractor on local machines by specifying it in package.json rather than installing it individually with the -g flag. The addition we made looks something like this: "scripts": { ...
Working with the Express.js framework and Node.js, I am trying to make a request to an MS SQL database on the server side. My goal is to retrieve data (in JSON or array format) from the server and send it to the client side. I'm unsure about how to ...
My task involves creating a table where users can edit certain fields in each row, which will impact other fields within the same row. Due to this requirement, I cannot use bind-once for all the rendered data. To address this issue, I attempted using the ...
It's no surprise that there are numerous questions addressing this issue, but each situation is unique and heavily context-dependent. Applying solutions from others to my own problem in a large React application with complex state has proven to be a c ...
In a recent project, I utilized react navigation's "createBottomTabNavigator" feature for tab navigation. const Tab = createBottomTabNavigator(); </Tab.Navigator> ................ <Tab.Screen name="Cart" component={Cart} /> ...
Something strange is happening to me. This peculiar behavior occurs only on the initial POST request. However, when I resubmit the form, the subsequent requests work perfectly fine. The first $http post call leads to the error function in .then, even thou ...