0

I have some requirement that needed to convert the given inline css element to external css using just my-control class, jsfiddle,

    <div class="control my-control">
        <div style="float: left;">
            <div style="padding-left: 3px; padding-top: 3px;">
                <div style="float: left;">Title:</div>
                <div style="float: left; padding-left: 12px"></div>
                <div style="clear: both"></div>
            </div>
            <div style="padding-left: 3px; padding-top: 3px;">
                <div style="float: left;">Lyrics:    </div>
                <div style="float: left; padding-left: 3px">
                    <div style="overflow: hidden; width: 180px; white-space: nowrap;" class="lyric-content"></div>
                </div>
                <div style="clear: both"></div>
            </div>
        </div>
        <div style="float: right; border-left: 1px solid black;">
            <img src="Content/Images/play.png" style="height: 50px;"></div>
    </div>
3
  • whats wrong in multiple class ? Commented Dec 31, 2012 at 7:11
  • @NullPointer, I am creating some controls internally. I have to only use one parent class. Commented Dec 31, 2012 at 7:12
  • @MarcinJuraszek, I am trying in Fiddle and using different combinations of ~ + > and finding lot of difficulties. Commented Dec 31, 2012 at 7:14

1 Answer 1

2

http://jsfiddle.net/pgfUT/4/

.control.my-control {
    overflow: hidden;
    display: block;
    border: 1px solid black;
    margin: 15px;
    width: 300px;    
}

.control.my-control > div {
    float: left;    
}

.control.my-control > div + div {
    float: right;
    border-left: 1px solid black;    
}

.control.my-control > div + div > img {
    height: 50px;
}

.control.my-control > div > div {
    padding-left: 3px;
    padding-top: 3px;
}

.control.my-control > div > div > div {
    float: left;
}

.control.my-control > div > div > div:last-child {
    float: none;
    clear: both;
}

.control.my-control > div > div > div + div {
    padding-left: 12px;
}

.control.my-control > div > div + div > div + div {
    padding-left: 3px;
}

.control.my-control > div > div > div > div.lyric-content {
    overflow: hidden;
    width: 180px;
    white-space: nowrap;
}

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.