简体   繁体   中英

Floating, Responsive side div (banner)

So I have a website and I wanted to create a responsive right side DIV where I would put responsive AdSense ads like this: 在此处输入图片说明

How can I make this DIV so it adapts to remaining space from the right side of the website? The closest I got is this (lets say website is fixed 900px width):

width:-moz-calc(100% - 900px);
width:-webkit-calc(100% - 900px);
width:calc(100% - 900px);

But 100% - 900px gives the width of left and right empty side spaces together, which is too wide... Can you help me somehow make this width adapt only to the width of the right side space?

When you calculate the width you have to divide it with 2 (left and right). So try the following:

width: calc((100% - 900px)/2);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM