BK14
BK14

Reputation: 11

CSS: Padding of text based on <div> width

say I have some text displayed on an html page, which is held in a <div> tag. The div has width: 100%. I want the text to be displayed at 3/4ths of the width of the div. So, if the divider is 1000px wide, I want the left padding of the text to be 750px. How can I do this? Thanks!

Upvotes: 1

Views: 430

Answers (2)

Vivek Shukla
Vivek Shukla

Reputation: 207

Here you have to first define the container width to 100% and then set padding to whatever % you want.

All calculations will be defined in %.

selector{
    width: 100%;
    padding-left: 75%; 
}

Upvotes: 2

prootex
prootex

Reputation: 39

div { 
    padding-left: 75%; 
    width: 100%;
}

Upvotes: -1

Related Questions