0

I want my logo to float outside the overflow:hidden div

This is my HTML Code:

    .login-card{
        width: 280px;
        background: rgb(255,250,250,0.6);
        margin-left: 45px;
        border-radius: 2px;
        box-shadow: 0 2px 2px rgba(0,0,0,.3);
        overflow: hidden;
    }

    .login-card img{
        width:70%;
        height:70%;
        margin-top: -25px;
        background-color: crimson; /*this is just to cover up the image*/
    }
   <div class="login-card">
        <img src="captiveportal-logo.png"/>
        <form name="login_form" method="">
            <input type="text">
            <input type="password">
            <input type="submit">
        </form>    
 </div>

I really want it to be half floating outside its div

לבני מלכה
  • 15,925
  • 2
  • 23
  • 47
CodeRed
  • 905
  • 1
  • 6
  • 24

1 Answers1

0

I think you need another extra outside container to overcome this issue. Look at the snippet. In this case you should aware about image size because it is now inheriting size from outside div where set the position: relative;

.outside {
 position:relative;
}
.login-card{
 width: 280px;
 background: rgb(255,250,250,0.6);
 margin-left: 45px;
 border-radius: 2px;
 box-shadow: 0 2px 2px rgba(0,0,0,.3);
 overflow: hidden;
}
.login-card img{
 width:100px;
 height:100px;
 position:absolute;
 left:0;
 top:-25px;
 background-color: crimson; /*this is just to cover up the image*/
}
<div class="outside">
<div class="login-card">
        <img src="https://via.placeholder.com/100.png/09f/fff"/>
        <form name="login_form" method="">
            <input type="text">
            <input type="password">
            <input type="submit">
        </form>
        <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
 </div>
</div>
Hanif
  • 3,739
  • 1
  • 12
  • 18