使Div出现在屏幕外的一半

sgc*_*lie 3 html css

有没有办法在div不知道宽度的情况下使用CSS 制作出现在屏幕外的半屏div

mag*_*lex 5

除非我误解了这个问题,否则我认为CSS 可能的,因为我希望从这个jsfiddle中可以清楚地看到.

示例HTML

<div class="container one">
   <div class="half">Hello there.</div>
</div>
   <div class="container two">
<div class="half">Hello there, you old dog.</div>
   </div>
<div class="container three">
   <div class="half">Hello there you old dog. Been up to your old tricks?</div>
</div>
Run Code Online (Sandbox Code Playgroud)

CSS

.container {
    position: absolute;
}
.half {
    position: relative;
    right: 50%;
}
.two {
    top: 30px;
}
.three {
    top: 60px;
}
Run Code Online (Sandbox Code Playgroud)