0

I cant remove border.

This is my code:

<mat-grid-list cols="2" rowHeight="2:1">
   <mat-grid-tile>
     <button mat-raised-button>1</button>
     <img id="image-diamond"/>
   </mat-grid-tile>
</mat-grid-list>

And css:

button{
width: 80%;
height: 70%; 
padding: 20px 40px;
font-size: 32px;
font-family: Arial, sans-serif;
display: inline-block;
background: linear-gradient(to right, #070600 0%, #f7d931f3 50%, #fae901f3 50%, #f7ef8bf3 100%);
background-size: 200% 100%;
background-position: 100% 0;
transition: background-position 0.3s;
opacity: 70%;
border: 1px solid #f00;
position: relative;
z-index: 1;
}

#image-diamond{
height: 20%;
width: 10%;
margin-top: 35%;
position: relative;
z-index: 2;
right: 5%;
overflow:hidden; 
background-repeat: no-repeat;
background-size: cover;
background-position: center;
}

And image have additional border. Set background transparent or border nothing change. Set thick on 0px also does not change anything, and when creating border there second border is still visable, and I can see 2 borders.

enter image description here

When I set border: 2px solid red; I can see white and red border.

enter image description here

4 Answers4

0

Try out this it

img {
  text-indent: -999px;
}
Kirubel
  • 1,461
  • 1
  • 14
  • 33
0

use border:none;

in both Like

   button{
border:none;
}
    
#image-diamond{
border:none;
}
Sagar Kumar
  • 148
  • 1
  • 8
0

add border: 0; and outline: none; - (remove black border) in button tag to css

button{
width: 80%;
height: 70%; 
padding: 20px 40px;
font-size: 32px;
font-family: Arial, sans-serif;
display: inline-block;
background: linear-gradient(to right, #070600 0%, #f7d931f3 50%, #fae901f3 50%, #f7ef8bf3 100%);
background-size: 200% 100%;
background-position: 100% 0;
transition: background-position 0.3s;
opacity: 70%;
border: 1px solid #f00;
position: relative;
z-index: 1;
border: 0;
outline: none;
}

#image-diamond{
height: 20%;
width: 10%;
margin-top: 35%;
position: relative;
z-index: 2;
right: 5%;
overflow:hidden; 
background-repeat: no-repeat;
background-size: cover;
background-position: center;
}
<mat-grid-list cols="2" rowHeight="2:1">
   <mat-grid-tile>
     <button mat-raised-button>1</button>
     <img id="image-diamond"/>
   </mat-grid-tile>
</mat-grid-list>
s.kuznetsov
  • 14,870
  • 3
  • 10
  • 25
0

You can't change it, that is the default browser behaviour.

Just like when an image has an invalid src and the browser shows a "broken image" icon, if an image has no src the browser shows a border to show where the image would be. For more information, see:

It looks like you want to set a background image - to do that, you don't use an img element, you can use some other element such as a div, e.g.

<div class="image-with-background"></div>

.image-background {
  height: 100px;
  width: 100px;
  background-image: url("https://lorempixel.com/output/technics-q-c-600-400-1.jpg");
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center;
}

See the example below:

.empty-img {
  height: 100px;
  width: 100px;
}

.image-background {
  height: 100px;
  width: 100px;
  overflow: hidden;
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center;
}

.background-url {
  background-image: url("https://lorempixel.com/output/technics-q-c-600-400-1.jpg");
}
<p>A "broken image" img element with no src: </p>
<img class="empty-img" />

<p>A div element tag with no backgrouund image, but using your background CSS -> no border: </p>
<div class="image-background"></div>

<p>A div element tag with a background image: </p>
<div class="image-background background-url"></div>
FluffyKitten
  • 13,824
  • 10
  • 39
  • 52