How to place 2 spans beside each other with full width with CSS

lukkysam

in my custom file manager I want to show truncated filenames. It's important to see the beginning and the ending, so just overflow:ellipsisdoesn't do the work.

The tiles where the filename is shown can change their width (inside bootstrap columns). They are rendered with handlebars, so I can manipulate the String before it's rendered (witch a helper). After that, I don't want to use javascript anymore (e.g. eventlisteners which listen to resize)

My Idea: Splitting the string of the filename (regex) while the tile is rendered. So "long_filename_with_number_at_the_end_001.jpg" becomes ["long_filename_with_number_at_the_end_","001.jpg"].

Now I want to include these strings in two spans inside a parent div, while the right span is as large as needed. and the left span fills the rest. The left span shall get the text-overflow:ellipsis property.

I found this answer, which is quite near to mine. I changed a little bit, but I did't get what I expected.

* {
    position: relaitve;
}
.outer {
    width: 110px;
    height: 22px;
    border: 1px solid #ccc;
}
#colA {
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
    background:yellow;
}
#colB {
    float:right;
    background: pink;
}
<div class="outer">
    <div id="colA">long_filename_foo_bar</div>
    <div id="colB">001.jpg</div>
</div>

SKeurentjes

Just switch #colA and #colB in your html document.

<div class="outer">
    <div id="colB">001.jpg</div>
    <div id="colA">long_filename_foo_bar</div>
</div>

JSFiddle: http://jsfiddle.net/skeurentjes/0nam7L2q/

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

Two DIVs beside each other without wrapper

분류에서Dev

How to place list items that are overlapping next to each other?

분류에서Dev

How to place 3 boxes nex to each other with some text inside it?

분류에서Dev

How to place buttons in the same line, center, and not too close to each other?

분류에서Dev

CSS table cell inputs not taking full width

분류에서Dev

2 div beside and 100%

분류에서Dev

Using HTML5 and CSS display 2 images level with each other, and each with a list below

분류에서Dev

How to "connect" objects in 2 classes to make them update each other?

분류에서Dev

How to animate an image as it grows from the width of a container to the full viewport width?

분류에서Dev

How to place image on part of other image

분류에서Dev

Bootstrap - 2 columns - make image full width on narrow screens

분류에서Dev

How to make 2 interfaces (of 2 different linux server) reachable to each other?

분류에서Dev

how to make amazon EC2 instances authenticate each other automatically?

분류에서Dev

how to put name and date beside image

분류에서Dev

GridBagLayout 2 JPanels - One less width than other

분류에서Dev

Issue with Calendar calculation that spans 2 calendar years

분류에서Dev

subset data only if observations of 2 variables match with each other in R

분류에서Dev

Select top 2 rows different from each other

분류에서Dev

Google Charts - How to stretch x axis over chart's full width

분류에서Dev

d3.js: how can I get 'full width' ticks on the y-axis

분류에서Dev

Unifont & UnicodeData.txt how do I deduce if character is full or half width (x-advance)

분류에서Dev

How to install php 7 to run beside php 5 on ubuntu with nginx

분류에서Dev

CSS 중간 정렬 TWO spans to the right of a image

분류에서Dev

how to make widgets float over each other in flutter

분류에서Dev

How to plot three histograms adjacent to each other for 3 given series?

분류에서Dev

Hi! how to put the div background image place side by side with the <ul> BUT with NO using FLOAT. Just with the width of every elements

분류에서Dev

Width Customization using css

분류에서Dev

makefile to link each other

분류에서Dev

How to get file path in browser (using protocol or other method to get full path)

Related 관련 기사

  1. 1

    Two DIVs beside each other without wrapper

  2. 2

    How to place list items that are overlapping next to each other?

  3. 3

    How to place 3 boxes nex to each other with some text inside it?

  4. 4

    How to place buttons in the same line, center, and not too close to each other?

  5. 5

    CSS table cell inputs not taking full width

  6. 6

    2 div beside and 100%

  7. 7

    Using HTML5 and CSS display 2 images level with each other, and each with a list below

  8. 8

    How to "connect" objects in 2 classes to make them update each other?

  9. 9

    How to animate an image as it grows from the width of a container to the full viewport width?

  10. 10

    How to place image on part of other image

  11. 11

    Bootstrap - 2 columns - make image full width on narrow screens

  12. 12

    How to make 2 interfaces (of 2 different linux server) reachable to each other?

  13. 13

    how to make amazon EC2 instances authenticate each other automatically?

  14. 14

    how to put name and date beside image

  15. 15

    GridBagLayout 2 JPanels - One less width than other

  16. 16

    Issue with Calendar calculation that spans 2 calendar years

  17. 17

    subset data only if observations of 2 variables match with each other in R

  18. 18

    Select top 2 rows different from each other

  19. 19

    Google Charts - How to stretch x axis over chart's full width

  20. 20

    d3.js: how can I get 'full width' ticks on the y-axis

  21. 21

    Unifont & UnicodeData.txt how do I deduce if character is full or half width (x-advance)

  22. 22

    How to install php 7 to run beside php 5 on ubuntu with nginx

  23. 23

    CSS 중간 정렬 TWO spans to the right of a image

  24. 24

    how to make widgets float over each other in flutter

  25. 25

    How to plot three histograms adjacent to each other for 3 given series?

  26. 26

    Hi! how to put the div background image place side by side with the <ul> BUT with NO using FLOAT. Just with the width of every elements

  27. 27

    Width Customization using css

  28. 28

    makefile to link each other

  29. 29

    How to get file path in browser (using protocol or other method to get full path)

뜨겁다태그

보관