I'm using Ionic2 and I want to make image and set an icon above the image when clicking the image I will upload image :
this is my code:
img {
-o-object-fit: cover;
object-fit: cover;
border-radius: 50%;
opacity: 0.6;
}
<img src="http://cdn.business2community.com/wp-content/uploads/2014/04/profile-picture.jpg"/><br/>
<button clear id="chgImg">Change Image</button><br/>
I want to set :
<ion-icon name="camera"></ion-icon>
above the image and in the center of it, what should I do?
Add a container to the image and button
.container{
position: relative;
}
Add the icon inside container
And set it's position to absolute.
Related
I have an Ion Content, I need to put a background image there with 50% Opacity.
My welcome component html
<ion-content>
<ion-grid>
<ion-row>
...
My welcome component scss
ion-content
{
--background: url(splash1.png) no-repeat center center / cover;
--background-opacity: 0.5;
}
The Background Image is shown, but there is no opacity. How I can fix it? I user Ionic v6 with Angular
use css shadow part background:
ion-content
{
--background: url(splash1.png) no-repeat center center / cover;
}
ion-content::part(background)
{
opacity: 0.5;
}
I want my modal to have a content (image), and a transparent background, but I can't achieve the transparent background, I will appreciate if you can help me.
Thank you very much!
Ionic CLI: 6.19.0
Ionic Framework: #ionic/angular 6.0.4
global.scss
.modal-answer .modal-wrapper {
--background: transparent !important;
margin: 0 auto;
height: 40%;
top: 30%;
width: 70%;
display: block;
}
game.ts
const modal = await this.modalController.create({
component: ModalAnswerPage,
cssClass: 'modal-answer',
componentProps: {
answe: this.ok_bad_time,
back_g: this.color_backg_modal_ answer'
}
});
return await modal.present().then(_ => {
});
modal-answer.page.scss
ion-content{
--background: transparent;
}
Remove your ion-content from you modal html. It inherit the background color from the component where you open the modal.
in you global.css :
ion-modal {
--background: transparent !important;
}
If this approach doesn't work, then instead you can add opacity to Modal parent element. For example :-
Modal component code :-
<div padding class="mainContent">
<div no-margin margin-top class="feedbackCard">
</div>
</div>
Here mainContent is complete page (transparent bg) and feedbackCard is the subpart (having white bg) and below is the CSS for above component
.mainContent {
flex: 1;
background-color: rgba(0, 0, 0, 0.3) !important;
justify-content: center;
align-content: center;
align-items: center;
display: flex;
}
.feedbackCard {
width: 100%;
border-radius: 4px;
background-color: white;
}
And you can open Modal using below code.
const modal = await this.modalCtrl.create({FeedbackComponent, 'backTransparent', {}});
modal.present();
global.scss
.backTransparent {
--background: transparent !important;
}
I use svg-icons in an app and the question is if it is necessary to put icons in different colors there or if I can set a color by code. Here is my approach:
app.scss:
ion-icon {
&[class*="custom-"] {
mask-size: contain;
mask-position: 50% 50%;
mask-repeat: no-repeat;
background: currentColor;
width: 1em;
height: 1em;
}
&[class*="custom-mobile"] {
background: url(../assets/mobile.svg);
}
}
view:
<ion-item>
<ion-icon name="custom-mobile"></ion-icon>
</ion-item>
I change the color of background in the class-part but no effect on view.
I have created html div (ie. 100X100) element that contains high resolution image(400X400) inside it. and when capture it generates image with same display on web page(100X100) i want to generate image larger(200X200) than div element. I cannot understand how can it possible.. can help me, thanks advance.
Here is a FIDDLE.
The upper div is an image 400x400, shrunk to 100x100.
The middle div is an image 400x400, shrunk to 50x50.
The bottom div is an image 50x50, enlarged to 100x100. - You can see "blurring" and pixelation.
CSS
.picturediv {
width: 100px;
height: 100px;
border: 4px solid blue;
margin: 0px auto;
}
.picturediv:nth-child(1) img {
height: 100px;
width: 100px;
}
.picturediv:nth-child(2) img {
height: 50px;
width: 50px;
}
.picturediv:nth-child(3) img {
height: 100px;
width: 100px;
}
Am using html, css to display an image.
IMG.displayed {
display: block;
margin-left: auto;
margin-right: auto;
vertical-align: middle
}
<IMG class="displayed" src="../images/splash.png" alt="...">
</IMG>
Its not displaying the image in the center of the screen (both vertically & horozontally).
your suggestions please.
To align an element both vertically & horizontally you could use the snippet below:
http://jsfiddle.net/catalinred/huKYW/
or
HTML:
<div>content here</div>
CSS
div
{
width: 300px;
height: 300px;
position: absolute;
top: 50%;
left: 50%;
margin-left: -150px;
margin-top: -150px;
background: red;
}