CSS Positioned Float in Reality

I'm in need of a specific feature that IE supports, which can be clearly seen in action at

However, the issue arises as no other web browsers seem to support the particular attribute required for this functionality.

How can I achieve a similar effect on all browsers except IE? (The element in question needs to have a fixed position while everything around it is dynamic.)

I've attempted using the "shape-outside" CSS attribute: http://jsfiddle.net/uniqueID

-webkit-shape-outside: polygon(0px 280px, 100% 280px, 100% 500px, 0px 500px);

Unfortunately, the outcomes are inconsistent (with issues like disabled line breaks in Chrome) or not supported at all (in Firefox).

It seems like resorting to Javascript to manually adjust the DOM element's position within the document flow will be necessary. Is there a way to accomplish this solely with CSS?

Answer №1

After some trial and error, I ended up implementing a solution like this: I created a function that would reposition the target block whenever the neighboring angular ng-repeat blocks changed or if the window was resized.

app.directive('onFinishRender', function ($timeout) {
  return {
    restrict: 'A',
    link: function (scope, element, attr) {
      if (scope.$last === true) {
        $timeout(function () {
          scope.$emit('ngRepeatFinished');
        });
      }
    }
  };
});


    var injectItem = function(ngRepeatFinishedEvent) {
      if (typeof(ngRepeatFinishedEvent) !== "undefined") {
        if (typeof(ngRepeatFinishedEvent.targetScope.item) === "undefined") {return;}
        //additional validation logic
      }
      var index = 2;
      if (window.innerWidth < 1200) {index=1;}
      if (window.innerWidth < 768) {index=0;}
      var secondRow = jQuery('.items').eq(index);
      var injectable = jQuery(".injectable").eq(0);
      if (!secondRow.next().hasClass('injectable')) {
        jQuery(".injectable:not(:first)").remove();
        secondRow.after(injectable.clone().css('display', 'block'));
      }
    };
    $scope.$on('ngRepeatFinished', injectItem);
    window.addEventListener('resize', function() {
      injectItem();
    });

<span class="injectable" style="display: none;">fixed position content here</span>
<span ng-repeat="item in items" on-finish-render class="item">
  surrounding content
</span>

this particular approach was inspired by Calling a function when ng-repeat has finished

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

CSS styling on top points gets lost when scrolling

My screen displays an image with bubbles scattered randomly, each positioned using CSS styles for top and left. Strangely, when I scroll, all the bubbles lose their top style and reposition themselves to the bottom of the image. If anyone has insight into ...

Jquery Mobile's CSS takes precedence over the CSS of my body

is causing conflicts with my body styling <body style="margin:0; padding:0; background-image:url(img/bggradient.jpg); background-repeat:repeat-x"> I have noticed that the color F6F6F6 is used 12 times in the css file, making it hard to manage. How ...

Why is the UI Router controller failing to function properly after loading the view from the $templateCache?

I've been utilizing gulp-angular-templatecache to convert my filename.view.html files into a consolidated templates.js file. Afterwards, I use $stateProvider to define states and fetch the templates from $templateCache, including an abstract "root" s ...

What's the best way to make sure an image and text are perfectly aligned on the

How can I align an image and text on the same line, as currently the a tag is higher than my text? Here is the HTML code: <div class="author-name"> <img class="article-author-img" src="{{ preload(asset('assets/st ...

Is there any more Angular code to be bound using ng-bind-html or ng-bind?

Hey there! Just a quick Angular inquiry: <div class="_minimal_size margin_10_middle"> <div class="_50 espaciado_0_20"> <p ng-bind-html="eirana_knows.feedback"></p> </div> <br class="clear"/> </div ...

What is the most efficient method to upgrade the Angular JS framework from version 1.2.2 to the newest 1.4.8?

What steps should be taken to upgrade a project from Angular JS version 1.2.2 to the latest 1.4.8? This project includes ASP.NET, web, api, and Angular JS in its application stack. Is it recommended to migrate from Angular JS versions 1.2.2 to 1.4.8? Co ...

The functionality of ngToast's newestOnTop feature is not performing as anticipated

I've been attempting to stack the toast messages generated by ngToast on top of each other. After reading through the documentation at , I came across a parameter labeled "newestOnTop". I implemented it in my app.coffee file like this: ngToastProvide ...

What is the best way to center the input on the page?

Does anyone know how to align the <input type="text"> in the center? I'm trying to create a login form but having trouble with positioning the input element. ...

AngularJS- numerous unique directives featured on a single page each with its distinctive state

Regarding the query about Calling a method in a directive controller from another controller. Is there a way to have multiple separate directives of the same type on a page? Since they share a common API (singleton), the state is also shared. Therefore, i ...

Tips for adding elements to an angular $scope.array?

Currently, I am facing an issue that I cannot seem to pinpoint (most likely due to my limited expertise in AngularJS). In my HTML file, I have a basic ng-repeat set up like this: <ul> <li ng-repeat="fot in fotografia"><img src="{{fot.path ...

Incorporating a URL into an HTML marquee

As a beginner in coding, I'm currently exploring how to incorporate a link into my marquee. My goal is to eliminate any color change or underline animation as well. Do you have any recommendations? .Marquee { color: #da6fe2; background-color: t ...

The issue arises when a continuous use of angularjs directives linked with an external template fails to display correctly upon the addition of new

In the code snippet below, you'll find a fiddle that displays 3 columns of numbers that increase in value. These columns represent directives with different templates: one inline, one preloaded, and one from an external template. When you click on the ...

Conceal element with transparent overlay without affecting the background

Looking to add animation to a snippet where the login menu rolls out? Consider two methods: adjusting the left position of the login menu or using another div on top to slowly reveal the login menu after moving it. The challenge lies in maintaining trans ...

JS form submission problem

Seeking advice on developing a functional contact form using HTML, CSS, and JavaScript. All conditions currently validate properly, but encountering an issue with error messages persisting after re-entering the required fields. Additionally, looking to red ...

Tips on stopping slideToggle from opening and closing when clicked for the first time

When using the slideToggle function, I'm encountering an issue where the content div briefly shows on the first click but then immediately slides closed. Subsequent clicks work as expected and slide open correctly. This is the Jquery script I have be ...

AngularJS POST request encounters failure: Preflight response contains improperly formatted HTTP status code 404

I have encountered a persistent issue with microframeworks while attempting to perform a simple POST request. Despite trying multiple frameworks, none of them seem to handle the POST request properly: Here is an example using AngularJS on the client side: ...

Determining if an invalid date was entered with Angular-Strap datepicker

Incorporating the Angular-Strap datepicker directive in a straightforward manner. When observing the home page for Angular-Strap, it is noted that when an invalid input is entered, the text field is highlighted with a red outline. Interestingly, this funct ...

Two distinct controllers: concealing elements through the operation of one of them

I am facing a challenge with my HTML elements: In one form-group, I have the following input: <div class="form-group"> <input type="search" ng-model="search"/> </div> This particular form-group needs to be hidden when another form-g ...

Using JavaScript to store CSS style properties in an array

In the midst of building a React-datagrid project, I am streamlining CSS properties for an array. However, there seems to be redundant CSS properties that I would like to consolidate into an array format. let _columns = []; let commonStyle = {"width":"20 ...

What could be causing bootstrap to suddenly stop working?

Running bootstrap on React and using Storybook to view it has been a smooth process until today. The code that worked flawlessly on Friday is suddenly not working at all. Despite trying it on Jsfiddle and onecompiler, the carousel component copied from the ...