GorillaApe
GorillaApe

Reputation: 3641

Responsive header with angle one side

When browser get resized absolutely positioned after pseudo-element overflows and causes problems. I am looking for a way to fix this. Just resize the browser until you reach header text.

wide header test text

Here is a demo of the problem: http://codepen.io/anon/pen/grKNoJ

.section {
  font-family: 'Quantico';
  font-weight: bold;
  font-size: 36px;
  color: white;
  border-top: solid 1px black;
  text-transform: uppercase;
  margin-bottom: 28px;
}

.section-title {
  background-color: black;
  display: inline-block;
  padding: 8px 18px;
  position: relative;
}
.section-title:after {
  content: " ";
  position: absolute;
  display: block;
  right: 0;
  height: 100%;
  top: 0;
  left: 0;
  z-index: -1;
  background: #000;
  transform-origin: bottom left;
  -ms-transform: skew(-30deg, 0deg);
  -webkit-transform: skew(-30deg, 0deg);
  transform: skew(-30deg, 0deg);
}

Upvotes: 0

Views: 93

Answers (1)

Johnny Kutnowski
Johnny Kutnowski

Reputation: 2390

You can fix it by adding text-overflow: ellipsis; and white-space: nowrap; to .section-title.

You could also set a max-width to that element, and set it to different values according to your media queries, and have it serve your needs on different devices.

Here is the updated result: http://codepen.io/johnnykb/pen/mPKZLg

Upvotes: 1

Related Questions