mardi 14 juin 2016

Expanding Divs with text

I have the following. However, I've been trying to get the blue title area to expand with the outter div and the arrow to be aligned in the middle. I have an outer div set at 25% just so the text wraps.

.breakingNewsRec {
  width: 100%;
  background: #FFF;
  position: relative;
  border: solid 2px #6A7791;
}
.breakingNewsRec>.bn-rec {
  width: auto;
  display: inline-block;
  background: #6A7791;
  position: relative;
  margin-right: 20px;
}
.breakingNewsRec>.bn-rec>h2 {
  display: inline-block;
  margin: 0;
  padding: 0 20px;
  line-height: 40px;
  font-size: 0.8em;
  color: #FFF;
  box-sizing: border-box;
}
.breakingNewsRec>.bn-rec>span {
  position: absolute;
  right: -10px;
  top: 10px;
  height: 0;
  border-style: solid;
  border-width: 10px 0 10px 10px;
  border-color: transparent transparent transparent #6A7791;
}
.breakingNewsTown {
  width: 100%;
  height: 40px;
  background: #FFF;
  position: relative;
  border: solid 2px #74936A;
}
.breakingNewsTown>.bn-rec {
  width: auto;
  height: 40px;
  display: inline-block;
  background: #74936A;
  position: relative;
  margin-right: 20px;
}
.breakingNewsTown>.bn-rec>h2 {
  display: inline-block;
  margin: 0;
  padding: 0 20px;
  line-height: 40px;
  font-size: 0.8em;
  color: #FFF;
  height: 40px;
  box-sizing: border-box;
}
.breakingNewsTown>.bn-rec>span {
  width: 0;
  position: absolute;
  right: -10px;
  top: 10px;
  height: 0;
  border-style: solid;
  border-width: 10px 0 10px 10px;
  border-color: transparent transparent transparent #74936A;
}
<div style="width: 25%">
  <div class="breakingNewsRec">
    <div class="bn-rec">
      <h2>Recreation News</h2><span></span>
    </div>fdsasdf asdif ksd jfkasjdfasj dfla sjdflj
    <img src="imgs/slides/slide2.jpg" width="25%">asdfljas dflkjsdf alskdjf asdfl</div>
  <div class="breakingNewsTown">
    <div class="bn-rec">
      <h2>Town News</h2><span></span>
    </div>fareveae vasev</div>
</div>

Aucun commentaire:

Enregistrer un commentaire