- This topic is empty.
-
AuthorPosts
-
October 8, 2016 at 12:24 pm #246299AyalaParticipant
Hi!
In my code the flex-grow doesn’t work.
I use it at first time, my code more complex than in the flex-box tutorials and examples, that’s why the simple examples can’t help me..
I don’t understand which class I have to write “flex-grow” in.
I want that the second div would be twice width than the first.My code:
http://codepen.io/Ayalann/pen/GjxpQbOctober 9, 2016 at 3:14 am #246331Paulie_DMemberA few things.
Firstly, you can’t apply a fixed width AND flex-grow.
Secondly, flex-grow only works if the parent element has
display:flex
. In this case the section has display flex but the links do not and the flexgrow divs are children of the link…not the section.It’s also not clear what look you are actually going for. Is the right side link supposed to be twice as big as the left…OR…is the text section of the link supposed to be twice as big as the picture?
Finally, flex-grow is NOT the same as width…If you want precise proportions, use percentages not flex-grow.
October 10, 2016 at 12:35 am #246377AyalaParticipantThank you for your answer!
I corrected some errors as you adviced.
I want that the right div (with picture and note too) would be twice big as left.
Now, the divs are in a coloumn, i don’t know why. They should be in a row.(I want to do it with flex-box, because I want to understand it. Now I am learning :)
Te new code:
http://codepen.io/Ayalann/pen/GjxGxQOctober 10, 2016 at 3:07 am #246380Paulie_DMemberSo you want something like this:
http://codepen.io/Paulie-D/pen/EgEdYq
Note, the parent
section
hasdisplay:flex
which means that if the links are supposed to be 1/3 to 2/3 THEY are the ones that need to have theflex-grow
value…in this case I just usedflex:1
etc. which is the shorthand.BUT, as I said, flexgrow is NOT the same as width. If you want the proportions to always stay the same you’ll need to use
flex-shrink
andflex-basis
.Note I have moved the text sections to outside the picture divs as it seemed that we waht you wanted.
October 10, 2016 at 4:15 am #246381AyalaParticipantNice!
But I don’t understant how could it work and in my site not.
There is something mistake.Could you see it, please?
Here, in the class “box” the “flex:1;” is disabled. Why?
I think I followed your example. Maybe the mistake is somewhere else.
I copied all here:
Maybe easier to see in this way:October 10, 2016 at 4:48 am #246382Paulie_DMemberflex:1
won’t work unless the parent hasdisplay:flex
.Also, you can’t relate the size of one element to another unless they are siblings inside the same parent.
October 10, 2016 at 5:06 am #246384AyalaParticipantThe parent has the display:flex.
In the class “galeria” and in “vateralink”, too.
class “vateralink” is the parents,
class “galeria” is parent of “vateralink.”They both have “display:flex”.
I don’t really understand what is the problem with the sizes.
October 10, 2016 at 6:43 am #246387Paulie_DMemberAlso, you can’t relate the size of one element to another unless they are siblings inside the same parent.
If
box1
andbox2
aren’t in the same element you can’t relate their sizes. There is NO CSS method that can do that.October 10, 2016 at 9:46 am #246389AyalaParticipantWhere should I write the size?
In your example you write max-width in the class of img, but it doesn’t work in my code.October 10, 2016 at 10:31 am #246390Paulie_DMemberWhere should I write the size?
You can’t….as I said..
If box1 and box2 aren’t in the same element you can’t relate their sizes. There is NO CSS method that can do that.
You’ll have to look into restructuring your HTML.
October 10, 2016 at 11:02 am #246391AyalaParticipantOh, so my html is wrong! I didn’t notice in your example that you put the “box” elsewhere, I was looking only the CSS.
Now I understand! Thank you very much for your help!!October 10, 2016 at 11:09 am #246392AyalaParticipantOne more question:
With this flex-box can I declare how many box would be in one row? -
AuthorPosts
- The forum ‘CSS’ is closed to new topics and replies.