イメージを表示するページがあります(現在は緑のdivプレースホルダのみです)。私はコメントボックスになり、残りのスペースの中心に画像を保持する右からdivをスライドさせたい。画像がこの残りのスペースには大きすぎる場合は、ユーザーが画像を水平にスクロールできるようにしたいと考えています。divを右からdivにスライドするときにdivを中央に配置する方法
私はこれ持っている:あなたは、コメントボックスが飛び出すが、それは代わりに、それが左に移動することの画像ホルダーのdivと重なって見ることができるようにhttps://jsfiddle.net/fwwfe2q6/
:
var showingComments = false;
$("#clickme").click(function() {
if (showingComments == false) {
showingComments = true;
$(this).parent().animate({
right: '0px'
}, {
queue: false,
duration: 500
});
} else {
showingComments = false;
$(this).parent().animate({
right: '-150px'
}, {
queue: false,
duration: 500
});
}
});
#Picture_container {
width: auto;
background-color: yellow;
overflow-x: auto;
}
#thePicture {
height: 300px;
width: 400px;
/* this will change when the page loads */
background-color: green;
left: 0px;
right: 0px;
margin-left: auto;
margin-right: auto;
}
#commentsBox {
background: #00FFFF;
position: absolute;
width: 150px;
height: 400px;
right: -150px;
top: 10px;
}
#clickme {
position: absolute;
top: 0;
left: 0;
height: 20px;
width: 400px;
background: #5F9EA0;
text-align: center;
transform: rotate(90deg);
transform-origin: left top 0;
}
#comments {
float: left;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id='Picture_container'>
picture container
<div id='thePicture'>
the picture goes here
</div>
</div>
<div id="commentsBox">
<div id="comments">
I am a sticky-out comments box
</div>
<div id="clickme">
click me!
</div>
</div>
例。コメントボックスの拡大と折りたたみ状態の両方に緑のdiv(画像を表す)を中央に配置し、拡大されたコメントボックスとともにウィンドウを収めるには大きすぎる場合、緑のdivを水平にスクロール可能にする方法を提案できますか?
選択肢で曲げるでしょうか?はい、ここにデモがありますhttps://codepen.io/gc-nomade/pen/VzoqjE –
はい、これは完全に機能すると思います。どうもありがとう。 – thecolin