Flex item width cannot be reduced, stretches to 100%

Clash Royale CLAN TAG#URR8PPP
Flex item width cannot be reduced, stretches to 100%
Not sure why but I cannot stop the red button from being 100% wide. Rather than stretching to 100% width, I'd rather make it as small as it can be. I can set max-widths, but if the text inside the button exceeds the width then that's no good. Displaying as flex, block, inline-block and inline don't work - neither does flex shink and flex grow to 0.
Can't actually identify what I'm doing wrong. Any ideas?
*
color: #000000;
margin: 0px;
padding: 0px;
font-family: 'Open Sans',verdana,helvetica,arial,sans-serif;
font-size: 100%;
box-sizing: border-box;
body max-width: 1088px
.divStyle6
width: 100%;
background: lightgreen;
display: flex;
justify-content: flex-start;
flex-direction: row;
.divStyle6 div width: 50%
.divStyle6 > div:first-of-type
background: url('https://www.encoreradio.co.uk/wp/wp-content/uploads/2018/08/mamma-mia.jpg');
background-position: top center; /* in case wrong aspect ratio image provided */
background-size: cover;
padding-bottom: 25%; /* aspect ratio 2:1 */
.divStyle6 > div:nth-of-type(2)
display: flex;
flex-direction: column;
justify-content: space-evenly;
padding: 3%;
.divStyle6 h3 margin: 0
.divStyle6 a.button
color: #fff;
background-color: #c43633;
transition: all 0.3s ease;
font-size: 12px;
padding: 13px 25px;
border: none;
text-decoration: none;
.divStyle6 a.button:hover background: #000
@media (max-width: 767px)
.divStyle6 flex-direction: column
.divStyle6 div width: 100%
.divStyle6 > div:first-of-type padding-bottom: 50%
.divStyle6 > div:nth-of-type(2) padding: 8%
<!-- BOOTSTRAP Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<div class="divStyle6">
<div></div>
<div>
<h3>random text goes here</h3>
<p>more random text here more random text here more random text here more random text here more random text here more random text here!</p>
<a class='button' href='#'>Click here</a>
</div>
</div>
1 Answer
1
Add property align-items: flex-start to your class ".divStyle6" . The button will take its width according to the content size (text).
align-items: flex-start
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.