5

I'm sorry in advance because I cannot show the code/images of what I'm working on due to confidentiality reasons, however I think I can explain it quite simply.

I have an <h1> element that acts as the title to my webpage - this title can change in length based on the title of the specific page the user is on, so it could say "Homepage" or it could say "Saved Projects", etc. The length varies.

The <h1> has a sibling element, a <ul>, that acts as a dropdown to navigate to these other pages.

My goal is to make the size of the dropdown be the same size as the <h1> at all times. Currently the width is explicit, I've tried 'auto' which did not work, naturally and am looking for other workarounds now but I figured I could post here in the meantime.

I am using LESS, so I know variables are big and it could be a matter of passing a variable as the value for the dropdown width, however I don't know if these variables can be dynamic based on the length of the <h1>. I am new to LESS.

I've browsed a couple other posts asking a similar questions, but none have gotten a very solid solution. Google also wasn't too helpful, most articles talked about parent-child sizes or keeping width/height relative. Not comparing widths of siblings.

Thanks for any assistance!

2540625
  • 11,022
  • 8
  • 52
  • 58
alex.mo.07
  • 305
  • 5
  • 14
  • 2
    Not really possible with CSS. CSS can't detect a width and apply it a sibling. If the second item was an absolutely positioned child...it could be done though. Personally, I'd go with JS/Jq. – Paulie_D Aug 06 '14 at 14:44
  • That was my concern, trying to see if I could avoid JS. Oh well. Thank you @Paulie_D – alex.mo.07 Aug 06 '14 at 16:35