I want the element to stick out from the left edge and display it.

Asked 2 years ago, Updated 2 years ago, 105 views

Thank you for your help.

I want the element to stick out from the left edge and display it.

to the parent element as shown in the code below. overflow:visible doesn't work.

Original condition (image 1)
Enter a description of the image here


Scroll to the right (image 2)
Enter a description of the image here

∧∧∧∧ ここ I want to show you the 100px part here.

I want to do this (image 3)
Enter a description of the image here

<body>
    <div class="container">
        <div class="box">
        </div>
    </div>
</body>

CSS

@charset "UTF-8";

*{
  margin:0;
  padding:0;
}

body{
    background:black;
}

US>.container{
    background:gray;
    width —500px;
    height —500px;
    position:relative;
    left: -100px;
    /* overflow:visible;error (correct)*/
}


.box{
    width —200px;
    height —200px;
    background:tomato;
}

html css

2022-09-30 21:26

1 Answers

Do you want to do something like this?

*{
  margin:0;
  padding:0;
}

body{
    background:black;
}

US>.container{
    background:gray;
    width —500px;
    height —500px;
    position:relative;
    /* left: -100px;deleted*/
    overflow:visible;
    margin-left: 100px; /* add */
}


.box{
    position: absolute; /* add */
    width —200px;
    height —200px;
    background:tomato;
    left: -100px; /* Added */
}


2022-09-30 21:26

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.